I have a ListView where:
public class RowData
{
public string Box1 { get; set; }
public string Box2 { get; set; }
public string Box3 { get; set; }
};
private ObservableCollection<RowData> Data = new ObservableCollection<RowData>();
...
MyListView.ItemsSource = Data;
I binded the properties of RowData with the DisplayMemberBinding property of my columns, for example:
MyGridViewColumn.DisplayMemberBinding = new Binding("Box1"));
I handle the ListViewItem.DoubleClick event:
private void ListViewItem_DoubleClick(object sender, MouseButtonEventArgs e)
{
ListViewItem item = sender as ListViewItem;
RowData data = item.DataContext as RowData;
data.Box1 = "new string";
}
But when I assign the new string to my data the ListView does not refresh its items (I can still see the old value of Box1, even if Box1 has a new value – a new double click shows that Box1 == "new string" before assigning the new string).
Why? How can I solve this problem?
You forgot to implement
INotifyPropertyChangedinterfaceAfter you updated any property in your data class you need to inform View to update itself.