zoukankan      html  css  js  c++  java
  • WPF打开子窗口给父窗口添加蒙版效果

    打开子窗体
    这是打开子窗体的代码,注释比较详细供大家参考

    private void Button_Click(object sender, RoutedEventArgs e)
            {
    
                EditGateLIst gatel = new WpfApplication1.EditGateLIst();//这是我要打开的新窗体
                //蒙板
                Grid layer = 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(layer);//在上面放一层蒙板
                //将装有原来内容和蒙板的容器赋给父级窗体
                MainWindows.Content = container;
                //弹出消息框 
                gatel.Owner = MainWindows;
                gatel.ShowDialog();
            }
    

      

    关闭子窗体

    private void Window_Closing(object 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;
            }
    

      本文引用自CSDN

  • 相关阅读:
    asp.net web api KnownTypeAttribute
    nodejs 递归创建目录
    nodejs 复制、移动文件
    windows cmd命令行下创建文件和文件夹
    nodejs http静态服务器
    C# Socket TCP Server & Client & nodejs client
    gem 安装nokigiri
    nsis 固定到任务栏
    SpringBoot整合JPA
    Freemaker FTL指令常用标签及语法
  • 原文地址:https://www.cnblogs.com/zunzunQ/p/15162982.html
Copyright © 2011-2022 走看看