protected override void OnKeyDown(KeyEventArgs e) { if (e.Key == Key.Enter) { caseKeyBox.CommitChanges(); e.Handled = true; } else if (e.Key == Key.Escape) { caseKeyBox.CancelChanges(); e.Handled = true; } }
public FlowSwitchCaseEditorDialog(ModelItem activity, EditingContext context, DependencyObject owner, string title, Type genericType) { this.WindowSizeToContent = SizeToContent.Manual; this.ModelItem = activity; this.Context = context; this.Owner = owner; this.Title = title; this.genericType = genericType; this.WindowResizeMode = ResizeMode.NoResize; this.MinWidth = 300; this.MaxWidth = 300; this.MinHeight = 120; this.MaxHeight = 120; caseKeyBox = new CaseKeyBox() { DisplayHintText = true, Visibility = Visibility.Visible, ValueType = genericType, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Width = Double.NaN, CommitExplicitly = true, LabelText = StringResourceDictionary.Instance.GetString("addCaseLabel"), }; caseKeyBox.ViewModel.DataTemplateName = CaseKeyBoxViewModel.BoxesTemplate; caseKeyBox.ViewModel.IsBoxOnly = true; caseKeyBox.SetBinding(CaseKeyBox.ValueProperty, new Binding() { Source = this, Path = new PropertyPath(FlowSwitchCaseEditorDialog.caseProperty), Mode = BindingMode.TwoWay }); caseKeyBox.CaseKeyValidationCallback = this.ValidateCaseKey; caseKeyBox.ValueCommitted += (sender, e) => { this.CloseDialog(true); }; caseKeyBox.EditCancelled += (sender, e) => { this.CloseDialog(false); }; this.Content = caseKeyBox; this.OnOk = () => { caseKeyBox.CommitChanges(); return(false); // ValueCommitted event handler will handle CloseDialog }; }
public FlowSwitchCaseEditorDialog(ModelItem activity, EditingContext context, DependencyObject owner, string title, Type genericType) { this.WindowSizeToContent = SizeToContent.Manual; this.ModelItem = activity; this.Context = context; this.Owner = owner; this.Title = title; this.genericType = genericType; this.WindowResizeMode = ResizeMode.NoResize; this.MinWidth = 300; this.MaxWidth = 300; this.MinHeight = 120; this.MaxHeight = 120; caseKeyBox = new CaseKeyBox() { DisplayHintText = true, Visibility = Visibility.Visible, ValueType = genericType, HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Width = Double.NaN, CommitExplicitly = true, LabelText = StringResourceDictionary.Instance.GetString("addCaseLabel"), }; caseKeyBox.ViewModel.DataTemplateName = CaseKeyBoxViewModel.BoxesTemplate; caseKeyBox.ViewModel.IsBoxOnly = true; caseKeyBox.SetBinding(CaseKeyBox.ValueProperty, new Binding() { Source = this, Path = new PropertyPath(FlowSwitchCaseEditorDialog.caseProperty), Mode = BindingMode.TwoWay }); caseKeyBox.CaseKeyValidationCallback = this.ValidateCaseKey; caseKeyBox.ValueCommitted += (sender, e) => { this.CloseDialog(true); }; caseKeyBox.EditCancelled += (sender, e) => { this.CloseDialog(false); }; this.Content = caseKeyBox; this.OnOk = () => { caseKeyBox.CommitChanges(); return false; // ValueCommitted event handler will handle CloseDialog }; }