tags:

views:

15

answers:

1

Hi, I have an application where users are editing rows. Using MVVM Pattern and wondering if I can hook a command whenever a cell is edited.

Is it possible? Thanks a lot.

+1  A: 

If I'm guessing correctly you have a ViewModel for the row, so you could just put some code into the setter for the cell value. What do you want to do with the command?

UPDATE: If you want to track which rows have changed just add an IsModified flag to your row ViewModel and set the flag in every property setter that's editable through your grid. No need for a command.

UPDATE: I've put together a small example to show what I meant.

public class RowViewModel
{
    private bool _IsModified = false;

    private string _FirstName;
    public string FirstName
    {
        get { return _FirstName; }
        set { _FirstName = value; _IsModified = true; }
    }

    private string _LastName;
    public string LastName
    {
        get { return _LastName; }
        set { _LastName = value; _IsModified = true; }
    }
}
andyp
yes i have a view model for the row.Need to save only those rows that have changed.I could setsome sort of tracking when an item is modified
No need for a command is good news.I will give it a go