ListBox, DataView, and DataTable.RejectChanges ()

I have a list box that is bound to a DataView.

<ListBox ItemsSource="{Binding Path=Categories}" DisplayMemberPath="Name"></ListBox>

where Categoriesis the property of the class that inherits the interface INotifyPropertyChanged:

public class EditCategoriesPresenter : INotifyPropertyChanged
{
    private DataTable _TableOfCategories;

    public DataView Categories { get { return _TableOfCategories.DefaultView; } }

    ...
}

While all data changes in the base DataTable(insertion and deletion of rows, changes to a column value) are automatically reflected in the list when I perform a row change DataTable.RejectChanges(), but the column value does not change.

I can understand why this is happening (it DataTable.RejectChangesdoes not cause any notifications about changes in the column values), but still cannot find an easy solution to solve it.

I also add OnPropertyChanged("Categories")after DataTable.RejectChanges(), but still no luck.

Any ideas?

Thanks in advance.

+3
source share
1

datatables, BindingListCollectionView , wpf . Refresh() ui.

public BindingListCollectionView Categories {get; private set;}

this.Categories = (BindingListCollectionView)CollectionViewSource.GetDefaultView(this._TableOfCategories);

//after reject
this.Categories.Refresh()

, ListBox ( xaml )? ?

+1

All Articles