Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF DataGrid: How do I databind the properties of the SelectedItem to trigger INotifyPropertyChangedEvents?
    primarykey
    data
    text
    <p>I'm trying to do this as MVVM as possible:<br /> My Model (<b>InterestTypeEntity</b>) implements INotifyPropertyChanged.<br /> My ViewModel (<b>InterestTypeAllViewModel</b>) has an ObservableCollection that binds to a DataGrid. When changes are made to it, it sends those changes (add/remove) to the Database.</p> <p>the problem is, I want to also be able to update the database when the properties of the objects within the collection change. I'm not sure how to do that? Here's my code so far...</p> <p>XAML:</p> <pre><code>&lt;DataGrid Name="TestGrid" Grid.Row="3" Grid.ColumnSpan="2" AutoGenerateColumns="False" ItemsSource="{Binding IntTypes}" SelectedItem="{Binding CurrentIntType}"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="Interest ID" Binding="{Binding IntType}" /&gt; &lt;DataGridTextColumn Header="Interested Parties Description" Binding="{Binding Description}" MaxWidth="500" /&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>ViewModel Code:</p> <pre><code>public ObservableCollection&lt;InterestTypeEntity&gt; IntTypes { get { return DataRepository.InterestTypeEntities; } } public InterestTypeEntity CurrentIntType { get; set; } public Int16 IntType { get { return CurrentIntType.IntType; } set { if (value != CurrentIntType.IntType) { CurrentIntType.IntType = value; OnPropertyChanged("IntType"); } } } public String Description { get { return CurrentIntType.Description; } set { if (value != CurrentIntType.Description) { CurrentIntType.Description = value; OnPropertyChanged("Description"); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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