8,734
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 显示子窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowChild_Click(object sender, RoutedEventArgs e)
{
ChildWindow1 childWindow = new ChildWindow1();
childWindow.Show();
childWindow.Closed += new EventHandler(ch_Closed);
}
void ch_Closed(object sender, EventArgs e)
{
ChildWindow1 child = (ChildWindow1)sender;
child.Visibility = Visibility.Collapsed;
//接着处理其他事件...
}
private void ChildWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (this.DialogResult == true &&
(this.nameBox.Text == string.Empty || this.passwordBox.Password == string.Empty))
{
e.Cancel = true;
ChildWindow cw = new ChildWindow();
cw.Content = "Please enter name and password or click Cancel.";
cw.Show();
}
}