private void window_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { _dataContext?.EndEdit(); _dataContext = (FileWrapper)DataContext; _dataContext?.BeginEdit(); }