简体   繁体   English

在mvvmlight for Windows 8中缺少EventToCommand行为 - 解决?

[英]Missing EventToCommand behaviour in mvvmlight for Windows 8 - Work Around?

Question says it all really :) 问题说这一切真的:)

I'm writing a Windows 8 app in XAML/C# using MVVM Light and I've noticed the EventToCommand feature hasn't been implemented yet. 我正在使用MVVM Light在XAML / C#中编写Windows 8应用程序,我注意到EventToCommand功能尚未实现。

Are there any work arounds for this that anybody can suggest? 是否有任何人可以建议的工作?

thanks! 谢谢!

You can now accomplish what EventToCommand used to do using the Behaviors SDK (XAML) for Visual Studio 2013 , without using other tools, (@localJoost 's WinRTBehaviors is deprecated now after it helped all of us those times) : 现在,您可以使用Visual Studio 2013行为SDK(XAML)来完成EventToCommand用于执行的操作,而无需使用其他工具(@localJoost的WinRTBehaviors现在在它帮助了我们所有人之后已弃用):

在此输入图像描述

An example of its use would be as follows : 其用途的一个例子如下:

<Slider x:Name="Sl_VolumeSilder">
        <Interactivity:Interaction.Behaviors>
            <Core:EventTriggerBehavior EventName="ValueChanged">
                <Core:InvokeCommandAction Command="{Binding OnSliderValueChangedCommand}" CommandParameter="{Binding ElementName=Sl_VolumeSilder, Path=Value}"/>
            </Core:EventTriggerBehavior>
        </Interactivity:Interaction.Behaviors>
</Slider>

Where Interactivity and Core are referenced : 引用交互性和核心的地方:

xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"

查看LocalJoost使用Reactive Extensions编写的EventToCommand行为: http ://dotnetbyexample.blogspot.be/2012/07/a-winrt-behavior-to-mimic-eventtocommand.html

I just did a blog post on that exact issue see my entry here. 我刚刚就这个问题做了一篇博文,请看我的参赛作品。

http://blog.tattoocoder.com/2012/08/getting-started-w-windows-8-mvvm-light.html http://blog.tattoocoder.com/2012/08/getting-started-w-windows-8-mvvm-light.html

Uses WinRTBehaviors and Win8nl from @localJoost 使用来自@localJoost的WinRTBehaviors和Win8nl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM