It seems to be a simple problem, but I can't get it to work.
I have a UserControl with the following property:
public ObservableCollection<HL7Message> source {get; set;}
And the following Binding:
<data:DataGrid x:Name="dgMessages" Grid.Row="2" AutoGenerateColumns="True"
ItemsSource="{Binding source}" ></data:DataGrid>
from a parent UserControl I set the value upon a button click:
messagesGrid.source = src; //messagesGrid is the name of the UserCntrol above
I'm expecting my DataGrid to be updated, but it's not. Can you please point at what I'm doing wrong?
Auto-properties sadly do not support change-notification. Therefore the DataGrid will not know that the collection has been changed if you set the
source
-Property.One possibility is to implement INotifiyPropertyChanged for the
messagesGrid.source
-Property:Please note, I have written the first letter of
Source
in UpperCase because in .net, properties are generally written so. You have to change your binding accordingly because Bindings are case sensitive.