views:

82

answers:

1

Hi, I have a WPf Toolkit-datagrid..in my application which follows MVVM pattern. How I can call a function in view-model if user selects a particular row in datagrid ?

A: 

in view

  <DataGrid ItemSource="{Binding MyItems}"
            SelectedItem = "{Binding MyCurrentItem}"
             >

in vm

private Myobject myCurrentItem;
public Myobject MyCurrentItem
                   {
                      get{ return myCurrentItem; }
                      set{
                            if (myCurrentItem!=value)
                            {
                               myCurrentItem=value;
                               DoMyStuff();
                            }                              
                         }
                    }
smash