Q:

Before and after bind events in wpf controls

Here is my situation: I have some datagrid controls, that allows users to sort by some columns. This is ok.
In some situations I need to reload the data. After reloading, datagrid loses the sort information.
So I thought to create my own datagrid that stores sorting information before binding and restore after binding.
Is there any events or something else that does that ?

A:

I had a similar situation some time ago. Here is my solution:
In xaml set NotifyOnTargetUpdated of DataGrid binding:
ItemsSource="{Binding MySourceData, NotifyOnTargetUpdated=True}"

and set the TargetUpdated event of this DataGrid:
TargetUpdated="MyGrid_TargetUpdated"

You can create your own DataGrid control that stores and restores sort information in the TargetUpdated event handler.

