WPF DataGrid Refresh problem

Nov 2, 2009 at 6:12 AM


I have used the following code to bind the list to my DataGrid. The Data are displayed correcttly in the datagrid. Consider 5 items in the list. So all 5 items are displayed in the DataGrid.

<my:DataGrid x:Name="DataGrid1" ItemSource="{Binding}" AutoGenerateColumns="True" />

List<I_Account> AccountList;
DataGrid1.DataContext = AccountList

By using the following code, if i delete any item from the AccountList then it is immediately reflecting in the DataGrid1.

But if apply sorting for any of the column in the WPF DataGrid and if i delete the item in the AccountList,  then it is not reflecting in the DataGrid. In debug mode, I am able see the count decreased to 4 in both List and DataGrid1. But it is not reflecting only in the UI.

This only happens after sorting. Please help me how to solve this.

Code To Remove the Item: