public void AddCommandBindings(UIElement host, SupportedPropertyCommands supportedCommands) { host.SetValue(ExpressionPropertyValueEditorCommands.ExpressionPropertyValueEditorCommandsProperty, (object)new ExpressionPropertyValueEditorCommands() { BeginTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnBeginTransaction(obj))), CommitTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnCommitTransaction(obj))), AbortTransaction = new ExpressionPropertyValueEditorCommand((ExpressionPropertyValueEditorCommandHandler)(obj => this.OnAbortTransaction(obj))) }); if ((supportedCommands & SupportedPropertyCommands.Transactions) == SupportedPropertyCommands.Transactions) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_BeginTransaction(), new ExecutedRoutedEventHandler(this.OnBeginTransaction))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_CommitTransaction(), new ExecutedRoutedEventHandler(this.OnCommitTransaction))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_AbortTransaction(), new ExecutedRoutedEventHandler(this.OnAbortTransaction))); } if ((supportedCommands & SupportedPropertyCommands.DialogEditor) == SupportedPropertyCommands.DialogEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyContainer.get_OpenDialogWindow(), new ExecutedRoutedEventHandler(this.OnOpenDialogWindow), new CanExecuteRoutedEventHandler(this.OnCanOpenDialogWindow))); host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowDialogEditor(), new ExecutedRoutedEventHandler(this.OnShowDialogEditor))); } if ((supportedCommands & SupportedPropertyCommands.PinnedEditor) == SupportedPropertyCommands.PinnedEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowExtendedPinnedEditor(), new ExecutedRoutedEventHandler(this.OnShowExtendedPinnedEditor))); } if ((supportedCommands & SupportedPropertyCommands.PopupEditor) == SupportedPropertyCommands.PopupEditor) { host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowExtendedPopupEditor(), new ExecutedRoutedEventHandler(this.OnShowExtendedPopupEditor))); } host.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.get_ShowInlineEditor(), new ExecutedRoutedEventHandler(this.OnShowInlineEditor))); host.SetValue(PropertyEditingHelper.SupportedPropertyCommandsProperty, (object)supportedCommands); }
private static void OnResourceValueModelChanged(object sender, DependencyPropertyChangedEventArgs args) { ResourceValueHost resourceValueHost = sender as ResourceValueHost; ResourceValueModel resourceValueModel = args.NewValue as ResourceValueModel; if (resourceValueHost == null || resourceValueModel == null) { return; } resourceValueHost.CommandBindings.Clear(); SupportedPropertyCommands supportedCommands = ~SupportedPropertyCommands.PinnedEditor; resourceValueModel.PropertyEditingHelper.AddCommandBindings((UIElement)resourceValueHost, supportedCommands); resourceValueHost.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.ShowExtendedPinnedEditor, new ExecutedRoutedEventHandler(ResourceValueHost.OnShowExtendedPinnedEditor))); PropertyInspectorHelper.SetOwningPropertyInspectorModel((DependencyObject)resourceValueHost, (IPropertyInspector)resourceValueModel); PropertyInspectorHelper.SetOwningPropertyInspectorElement((DependencyObject)resourceValueHost, (UIElement)resourceValueHost); }