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

loo*_*ris 6 c# mvvm-light windows-8 winrt-xaml

问题说这一切真的:)

我正在使用MVVM Light在XAML/C#中编写Windows 8应用程序,我注意到EventToCommand功能尚未实现.

是否有任何人可以建议的工作?

谢谢!

Aym*_*udi 14

现在,您可以使用Visual Studio 2013行为SDK(XAML)来完成EventToCommand用于执行的操作,而无需使用其他工具(@localJoost的WinRTBehaviors现在在它帮助了我们所有人之后已弃用):

在此输入图像描述

其用途的一个例子如下:

<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>
Run Code Online (Sandbox Code Playgroud)

引用交互性和核心的地方:

xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
Run Code Online (Sandbox Code Playgroud)


Bar*_*art 4

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