日期:2014-05-17 浏览次数:20858 次
private ShowWindow _ShowWindow;
public Window5()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Window5_Loaded);
this.Unloaded += new RoutedEventHandler(Window5_Unloaded);
}
void Window5_Unloaded(object sender, RoutedEventArgs e)
{
if (_ShowWindow!=null)
{
_ShowWindow = null;
}
}
void BtnShowWindow(object sender,RoutedEventArgs e)
{
if (_ShowWindow == null)
{
_ShowWindow = new ShowWindow();
}
_ShowWindow.Show();
}
Fomr1 form1;//申明为类成员
//下列代码放在需要打开窗体那
if (form1 == null
------解决方案--------------------
form1 .IsDisposed )//先判断窗体实例是否存在
{
form1 = new Form1();
form1.Show();
}
else
{
form1.WindowState = FormWindowState.Normal;
form1.Show();
}