Wednesday, September 10, 2014

Xaml Binding EventToCommand to MVVM core

I have worked my way through Stuart Lodge's N+1 tutorials.
I was stumped about how to connect my Icommand control from the core to the UI.
Stuart's demo showed how to connect a button or checkbox to the MvxCommand but did not explain how to use the EventToCommand relationship.

I was trying to have a stackpanel fire the event when the user taps it in the UI.
The stackoverflow article provided me the leg up I needed.

I was struggling on which syntax to use to associate a stackpanel in xaml with my command. Turns out I needed to reference the Cirrious namespace in the xaml


xmlns:Commands="clr-namespace:Cirrious.MvvmCross.WindowsPhone.Commands;assembly=Cirriou... xmlns:Commands="clr-namespace:Cirrious.MvvmCross.WindowsPhone.Commands;assembly=Cirrious...

<i:Interaction.Triggers >
   <i:EventTrigger EventName="Tap">
      <Commands:MvxEventToCommand Command="{Binding OnItemTappedCommand}" />
   </i:EventTrigger >
</i:Interaction.Triggers>
Source:
http://stackoverflow.com/questions/16823444/im-getting-build-errors-when-using-mvxeventtocommand-within-a-wp8-project

https://github.com/MvvmCross/MvvmCross/blob/e6d10972b5c28e00e80acc3d9e8910961aa813d6/Cirrious/Cirrious.MvvmCross.WindowsPhone/Commands/MvxEventToCommand.cs


No comments:

Post a Comment