Using IEditableObject in Silverlight

I have an object that implements the IEditableObject interface, opened on a viewmodel, bound to a Silverlight page.

How / Where can I call BeginEdit, CancelEdit and EndEdit methods? How can I restrict only objects that implement this interface to my page?

I DO NOT use DataGrid or DataForm controls. I use Label, TextBox, and DescriptionViewer elements to display data for editing.

+1
source share
1 answer

I know this is an old thread (but for the sake of future use ...)

I do like this:

whenever the current item (e.g. CollectionViewSource) changes, this is done:

void View_CurrentChanged(object sender, EventArgs e)
        {
            if (culturesView.Source != null)
            {
                ((IEditableObject)SelectedRecord).BeginEdit();
                RaisePropertyChanged("SelectedRecord");

            }
        }

, ( ), :

 private void Save()
{
 ((IEditableObject)SelectedRecord).EndEdit();
//do the actual saving to the dbms here ....

}

, ( ), :

private void Cancel()
{            
((IEditableObject)SelectedRecord).CancelEdit();
            //allthough we have canceled the editing we have to re-enable the edit mode (because
            //the user may want to edit the selected record again)
            ((IEditableObject)SelectedRecord).BeginEdit();

}

, - !

+6

Source: https://habr.com/ru/post/1764061/


All Articles