Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGrid - change edit behaviour
    primarykey
    data
    text
    <p>I have an ObservableCollection of ChildViewModels with somewhat complex behaviour.</p> <p>When I go to edit a row - the DataGrid goes into 'edit-mode' - this effectively disables UI-notifications outside the current cell until the row is committed - is this intended behaviour and more importantly can it be changed?</p> <p>Example:</p> <pre><code>public class ViewModel { public ViewModel() { Childs = new ObservableCollection&lt;ChildViewModel&gt; {new ChildViewModel()}; } public ObservableCollection&lt;ChildViewModel&gt; Childs { get; private set; } } public class ChildViewModel : INotifyPropertyChanged { private string _firstProperty; public string FirstProperty { get { return _firstProperty; } set { _firstProperty = value; _secondProperty = value; OnPropetyChanged("FirstProperty"); OnPropetyChanged("SecondProperty"); } } private string _secondProperty; public string SecondProperty { get { return _secondProperty; } set { _secondProperty = value; OnPropetyChanged("SecondProperty"); } } private void OnPropetyChanged(string property) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(property)); } public event PropertyChangedEventHandler PropertyChanged; } </code></pre> <p>And in View:</p> <pre><code>&lt;Window.Resources&gt; &lt;local:ViewModel x:Key="Data"/&gt; &lt;/Window.Resources&gt; &lt;DataGrid DataContext="{Binding Source={StaticResource Data}}" ItemsSource="{Binding Childs}"/&gt; </code></pre> <p>Notice how the second notification when editing first column is hidden until you leave the row.</p> <p>EDIT: Implementing IEditableObject does nothing:</p> <pre><code>public class ChildViewModel : INotifyPropertyChanged,IEditableObject { ... private ChildViewModel _localCopy; public void BeginEdit() { _localCopy = new ChildViewModel {FirstProperty = FirstProperty, SecondProperty = SecondProperty}; } public void EndEdit() { _localCopy = null; } public void CancelEdit() { SecondProperty = _localCopy.SecondProperty; FirstProperty = _localCopy.FirstProperty; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload