Reputation: 19061
I have DataGrid with dataBinding:
<sdk:DataGrid x:Name="colorGrid" Height="160" Margin="0,5,0,10" RowHeight="40" AutoGenerateColumns="False" >
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn
Header="Id"
Width="150"
Binding="{Binding ColorId}"
FontSize="20" />
<sdk:DataGridTextColumn
Header="Color"
Width="150"
Binding="{Binding Color}"
FontSize="20" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
I set ItemSource:
colorGrid.ItemsSource = Colors;
After that I change element of my Colors
. What should I do for update data in DataGrid
?
Upvotes: 0
Views: 355
Reputation: 564851
You shouldn't need to do anything, provided your bound types (Colors
) implement INotifyPropertyChanged
, and the collection implements INotifyCollectionChanged
. This will cause your DataGrid
to automatically update as elements update.
(The INPC interface will allow changing a property within one color element to be reflected in the DataGrid. The INCC interface will allow adding a new Color or removing a Color to be reflected properly.)
Upvotes: 3