Handling MVVM WinRT Events

How do you handle events in MVVM in metro applications? I used the interaction class and EventToCommand from MVVM light in WPF, but it looks like there is no interaction in WinRT. There are also no triggers, so should I "use the ugly path"? (code behind and

(this.DataContext as ViewModel).Command.Execute()

eg?)

+4
source share
2 answers

The best alternative to EventToCommand I have found so far is the attached team solution, which was shown in this CodeProject article .

And this is how it is used.

 <Button Content="Test Button" local:AttachedCommand.RoutedEvent="PointerEntered" local:AttachedCommand.Command="{Binding TestCommand}"/> 

Another alternative is to simulate the behavior of EventToCommand Joost van Schaik, but for me it was too hard, given the required dependencies.

+1
source

Attach commands using the same method as we do, in Silverlight, with the exception of binding to the viewmodel, the interface and the class that implements it will be used. This class should be used as a locator in the datacontext and declared in the app.xaml.cs file. Please let me know if you need more information.

0
source

All Articles