I am very new to WPF so forgive me if the question doesn't make sense. Is there an event that is fired before data context change? I want to commit the pending data changes before the data context is switched away.
There is no DataContextChanging
event, but the DataContextChanged
event provides the old value of the DataContext
:
private void Window_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
object oldDataContext = e.OldValue;
...
}