private void removeWindow() { // 关闭窗口 WindowEntryFactory.CloseWindow(mFocusBtn.Tag as IWindowEntry); int index = stackPanel.Children.IndexOf(mFocusBtn); mWins.Windows.Remove(mFocusBtn.Tag as IWindowEntry); stackPanel.Children.Remove(mFocusBtn); // 聚焦到后面一个Window if (index < stackPanel.Children.Count) { stackPanel.Children[index].Focus(); } else if (index > 0) { stackPanel.Children[index - 1].Focus(); } if (stackPanel.Children.Count == 0) { HideWin(); } else { resetWindowSize(); } }