private void OnKeyDown(object sender, KeyEventArgs e) { Control ctrl = sender as Control; if (ctrl != null) { if (e.Key == Key.Escape || e.Key == Key.Enter) { ContractParamVM contractVM = ctrl.DataContext as ContractParamVM; if (contractVM != null) { if (e.Key == Key.Enter) { contractVM.UpdateContractParam(); } else { ctrl.DataContext = null; ctrl.DataContext = contractVM; } } ctrl.Background = Brushes.White; } else { ctrl.Background = Brushes.MistyRose; } } }
private void OnParamChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { FrameworkElement ctrl = sender as FrameworkElement; ContractParamVM contractParamVM = ctrl.DataContext as ContractParamVM; if (contractParamVM != null) { contractParamVM.UpdateContractParam(); } }