private void Attach() { _ownerWindow = WorkspaceWindow.GetOuterWorkspaceWindow(_ownerView.Control); var workSpace = App.Current.Workspace; if (this.EnableAlertOnWindowActiving) { workSpace.WindowActiving += Workspace_WindowActiving; } workSpace.WindowClosing += workSpace_WindowClosing; workSpace.WindowClosed += workSpace_WindowClosed; }
public void AddCommand(WPFCommand cmd, object commandArg = null) { if (commandArg == null) { var window = WorkspaceWindow.GetOuterWorkspaceWindow(this.InnerContent) as ModuleWorkspaceWindow; if (window == null) { throw new ArgumentNullException("内部控件没有 WindowTemplate 时,必须提供 commandArg 参数。"); } commandArg = window.MainView; } var items = commandPanel.Items; items.Remove(btnConfirm); items.Remove(btnCancel); AutoUI.BlockUIFactory.AppendCommands(commandPanel, commandArg, cmd); //始终把 btnConfirm、btnCancel 放到最后。 items.Add(btnConfirm); items.Add(btnCancel); //commandPanel.Style = RafyResources.Rafy_CommandsContainer_Style; //Button btn = new Button() //{ // Margin = new Thickness(10, 2, 20, 2), //}; //commandPanel.Children.Insert(0, btn); //if (window != null) //{ // btn.CommandParameter = window.View; //} //else // btn.CommandParameter = View; //ButtonCommand.SetCommand(btn, CommandRepository.NewCommand(commandName)); }