简体   繁体   中英

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.

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) :

在此输入图像描述

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

Uses WinRTBehaviors and Win8nl from @localJoost

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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