打开子窗体
这是打开子窗体的代码,注释比较详细供大家参考
private void Button_Click( sender, RoutedEventArgs e)
{
EditGateLIst gatel = new WpfApplication1.EditGateLIst();//这是我要打开的新窗体
//蒙板
Grid = new Grid() { Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0)) };
//父级窗体原来的内容
UIElement original = MainWindows.Content as UIElement;//MainWindows父窗体
MainWindows.Content = null;
//容器Grid
Grid container = new Grid();
container.Children.Add(original);//放入原来的内容
container.Children.Add( );//在上面放一层蒙板
//将装有原来内容和蒙板的容器赋给父级窗体
MainWindows.Content = container;
//弹出消息框
gatel.Owner = MainWindows;
gatel.ShowDialog();
}
关闭子窗体
private void Window_Closing( sender, System.ComponentModel.CancelEventArgs e)
{
//容器Grid
Grid grid = this.Owner.Content as Grid;
//父级窗体原来的内容
UIElement original = VisualTreeHelper.GetChild(grid, 0) as UIElement;
//将父级窗体原来的内容在容器Grid中移除
grid.Children.Remove(original);
//赋给父级窗体
this.Owner.Content = original;
}
继续阅读与本文标签相同的文章
上一篇 :
Markdown简单常用语法
下一篇 :
说到密码就只知道ABC123?你OUT了!
-
首个二类资源区平价光伏电站正式并网发电
2026-05-14栏目: 教程
-
AI+5G科技创新 视频行业呈现轻应用化趋势
2026-05-14栏目: 教程
-
1.98亿滴滴用户添加了紧急联系人 每天百万个订单行程分享给亲友
2026-05-14栏目: 教程
-
工程院院士刘韵洁:5G前景很大,但主要是行业应用
2026-05-14栏目: 教程
-
陆奇:看好5G技术,但应用好5G还需要时间
2026-05-14栏目: 教程
