This is a migrated thread and some comments may be shown as answers.

Calling Command on RowEditEnded for MVVM

1 Answer 585 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CLAUDIO ROSSI
Top achievements
Rank 1
CLAUDIO ROSSI asked on 04 Apr 2011, 09:28 AM
Hi at all .
 
I am working with Wpf RadGridWiew and would like to save data to database with a MVVM command where i receive my modified item placed in my VIEWMODEL automatically every time that i change one row of data.

How can i do so ?

Best regards

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 Apr 2011, 02:18 PM
Hi CLAUDIO ROSSI,

A possible approach may be to use EventTriggers and invoke the command you want on RowEditEnded. For example:

<telerik:RadGridView Grid.Row="0"
                            Name="clubsGrid"
                            ItemsSource="{Binding Clubs}"
                            AutoGenerateColumns="False"                          
                            Margin="5">
           <i:Interaction.Triggers>
               <i:EventTrigger EventName="RowEditEnded" >
                   <i:InvokeCommandAction Command="{Binding MyCommand}" />
               </i:EventTrigger>
           </i:Interaction.Triggers>          
            
       </telerik:RadGridView>

In this case MyCommand is a custom command defined in your ViewModel. However, you may use the built-in CommitEdit command. 
Another possible approach may be to bind the CurrentItem or SelectedItem of the grid to a particular property in you ViewModel and once a PropertyChanged in raised to save those changes.
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
CLAUDIO ROSSI
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or