方法一:
Window window = new Window();
window.ShowDialog;
方法二: 设置一个判断窗口打开状态的全局控制变量
private bool isOpened = false;
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!isOpened)
{
isOpened = true;
Window window = new Window();
window.IsVisibleChanged += (e2, o2) =>
{
isOpened = window.IsVisible ? true : false;
};
window.Show();
}
}