private void SetActiveCommand(ICommand command) { if (this.CommandProvider == null) { Content = null; return; } var factory = command == null ? null : command.GetFactory(); var editor = (factory == null) ? null : factory.GetCommandEditor(this.CommandProvider); var editorFrameworkElement = editor as FrameworkElement; if (editorFrameworkElement != null) { editorFrameworkElement.DataContext = command; } // Must be after setting the data context Content = editor; }
private void SetCommandFactoryFromCommand(ICommand command) { this.updatePriority = PriorityItem.Command; if (CommandProvider == null) { return; } this.updatePriority = PriorityItem.None; if (command == null) { CommandFactory = null; return; } this.allowPropertyBehaviours = false; try { CommandFactory = CoerceCommandFactory(command.GetFactory()); } finally { this.allowPropertyBehaviours = true; } }