private void form_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { EDOUtils.UpdateViewOfVM(this); if (FormVM != null) { // Debug.WriteLine("IsLoaded=" + IsLoaded); if (IsLoaded) { // *In most cases form_Loaded will be called so then InputBinding should be set. // *But when the tab is changed opening multiple Study Unit files using EventFormView // Confirmed that form_Loaded was not called and InputBinding was not set as a result. // *In above case, DataContext seems to be modified keeping IsLoaded=true, so here I set InputBindings. // *Because it is called in the order of form_DataContextChanged (IsLoaded = false) -> form_Loaded, so never InputBindings is set twice // *In the case of IsLoaded=false, DataGridHelper.FindDataGrid(this, "universeDataGrid") might return null. SetupDataGridInputBindings(); } } OnFormDataContextChanged(); }