tags:

views:

62

answers:

1

Hi

We have some WPF/Silverlight controls we have written using the traditional event architecture (no commands etc.), and want to convert it to MVVM compliant ones. I researched on this subject, and i take it i will have to write commands to wrap the events that i currently have in the control. I would like to design it correctly now so i want to also make it RX complaint, rather than just commands.

Can someone explain to me how i can design my currently designed events into commands and RX ones please.

It will be useful if we took something like a control's Click event, and design command for it, and also RX compliant (observable, etc.), so i can understand what is involved.

Currently it is simple events, its pretty simple to understand to work with it :)... so one can subscribe to it and execute custom handlers. My employer wants me to make this commands and also RX-ify it.

I read some articles on these, but found it to require some PhD degree to understand (mathematical Dual, Subject<T>, etc.) :) I could not get my heads around it. I am struggling to taking this and making it into commands and also into RX. Please help. I want to learn this properly, so i don't have to re-design it again once more.

Thanks in advance.

A: 

I have no idea about ReactiveXaml but if you want to bind events to command, I could advise you MVVM light. You can try something similar to the code below, moreover MVVM light is provided with an EventToCommand Sample:

<Window 
   ... 
  xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
  xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras" 
  />
 <ComboBox ItemSource="{Binding MyCollection}">
    <Interactivity:Interaction.Triggers>
      <Interactivity:EventTrigger EventName="SelectionChanged">
         <cmd:EventToCommand Command="{Binding Path=LoadCommand}" />
      </Interactivity:EventTrigger>
    </Interactivity:Interaction.Triggers>
  </ComboBox>
AmineK
Or just the Attached Command Behavior (https://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/) if you don't want to use a full toolkit.
Bryan Anderson