I have a list box which is binded to a DataView.
<ListBox ItemsSource="{Binding Path=Categories}" DisplayMemberPath="Name"></ListBox>
where Categories is a property to class that inherits the INotifyPropertyChanged interface:
public class EditCategoriesPresenter : INotifyPropertyChanged
{
private DataTable _TableOfCategories;
public DataView Categories { get { return _TableOfCategories.DefaultView; } }
...
}
While all data changes to the underlying DataTable (row inserts and deletes, column value changes) are reflected to list box automatically, when I do a DataTable.RejectChanges() row changes are reflected but not column value changes.
I can understand why this is happening (the DataTable.RejectChanges does not raise any notifications for column value changes) but still cannot find any easy solution to solve it.
I also add the OnPropertyChanged("Categories") after DataTable.RejectChanges() but still no luck.
Any ideas?
Thank you in advance.
when i work with datatables i always use BindingListCollectionView for binding, cause wpf do this anyway implicitly. but now i can use the Refresh() method to refresh my ui binding.
public BindingListCollectionView Categories {get; private set;}
this.Categories = (BindingListCollectionView)CollectionViewSource.GetDefaultView(this._TableOfCategories);
//after reject
this.Categories.Refresh()
nevertheless, what does your ListBox looks like (just the xaml you posted or some datatemplates too)? can you post a screenshot?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With