[DllImport("user32.dll")]
  public static extern IntPtr GetAncestor(IntPtr hWnd, int flags);
 var dialog = new CustomiDalog();

            window = new Window();
            window.Content = dialog;
            window.ShowInTaskbar = false;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.SizeToContent = SizeToContent.WidthAndHeight;
            window.WindowStyle = WindowStyle.ToolWindow;
            var elementSource = HwndSource.FromVisual(rtb) as HwndSource;
            if (elementSource != null)
            {
                int GA_ROOT = 2;
                IntPtr root = GetAncestor(elementSource.Handle, GA_ROOT);
                new WindowInteropHelper(window).Owner = root;
            }
注意:如果dialog里面有事件需要注册。。先注册事件再
window.ShowDialog();

才有效果
												

wpf window set window的owner的更多相关文章

  1. WPF直接用Window.Close直接关闭窗口导致不能完全退出的问题

    前几天我在CSDN扔了一个问题,基本描述一下:写了一段这样的代码,来实现获取Control的template,却发现一个这样的问题,就是当我打开了一个window以后,手动调用Close(),窗口的确 ...

  2. C# WPF 多个window 相互覆盖的次序控制 不用topmost

    原文:C# WPF 多个window 相互覆盖的次序控制 不用topmost   WindowInteropHelper mianHanel = new WindowInteropHelper(Mai ...

  3. WPF Aero Glass Window

    原文:WPF Aero Glass Window 用法 Win7 DwmSetWindowAttribute function Win10 SetWindowCompositionAttribute ...

  4. WPF 不要给 Window 类设置变换矩阵(分析篇):System.InvalidOperationException: 转换不可逆。

    原文:WPF 不要给 Window 类设置变换矩阵(分析篇):System.InvalidOperationException: 转换不可逆. 最近总是收到一个异常 "System.Inva ...

  5. WPF 不要给 Window 类设置变换矩阵(应用篇)

    原文:WPF 不要给 Window 类设置变换矩阵(应用篇) WPF 的 Window 类是不允许设置变换矩阵的.不过,总会有小伙伴为了能够设置一下试图绕过一些验证机制. 不要试图绕过,因为你会遇到更 ...

  6. WPF 中保存 window(窗口)或者canvas成图片

    最近需要用到这个功能,搜了一下不少代码有问题 ,找到一个效果比较好的,支持多级子元素 记一下. private void button_save_window_Click(object sender, ...

  7. 关于 window.parent, window.top, window.self 详解

    在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口,opener是用open方法打 ...

  8. jquery源码中的(function(window, undefined){})(window)【转】

    (function( window, undefined ) {})(window);这个,为什么要将window和undefined作为参数传给它? (function( $, undefined ...

  9. JS 关于(function( window, undefined ) {})(window)写法的理解

    JS 关于(function( window, undefined ) {})(window)写法的理解 [网络整理] (function( window, undefined ) {})(windo ...

随机推荐

  1. uniq 重复行统计

    uniq 命令   文字 uniq 是LINUX命令 用途 报告或删除文件中重复的行. 语法 uniq [ -c | -d | -u ] [ -f Fields ] [ -s Characters ] ...

  2. c++ 调用外部程序exe-ShellExecuteEx

    此方法最实用的调用exe. #include <ShellAPI.h> string file_path = s_run_dir+"\\ConsoleApplication1.e ...

  3. FFMpeg 滤镜中英文对照

    FFMpeg ver 20160213-git-588e2e3 滤镜中英文对照 2016.02.17 by 1CM T.. = Timeline support 支持时间轴 .S. = Slice t ...

  4. stream的seek方法实例

    using (FileStream outStream = new FileStream(@"D:\12.txt", FileMode.Open)) { using (FileSt ...

  5. Greedy:Paint Color(AOJ 0531)

    涂颜料 题目大意:在一个1000000*1000000的矩阵中放入几块木板,问你这些木板把矩阵划分成了几个区域?输入会给左下角和右上角的坐标,输入W==0且H==0结束. 这一题是书上的作业题,书上有 ...

  6. tp5文件上传

    //tp5上传文件先 use think\File; //上传文件处理 $file = request()->file('file'); // 获取表单提交过来的文件 $error = $_FI ...

  7. 【leetcode】Word Search (middle)

    今天开始,回溯法强化阶段. Given a 2D board and a word, find if the word exists in the grid. The word can be cons ...

  8. mysql my.cnf配置文件详解

    本配置文件针对Dell R710,双至强E5620.16G内存的硬件配置.CentOS 5.6 64位系统,MySQL 5.5.x 稳定版.适用于日IP 50-100w,PV 100-300w的站点, ...

  9. httpclient 支持代理和http & https

    import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.Inpu ...

  10. python基础——继承和多态

    python基础——继承和多态 在OOP程序设计中,当我们定义一个class的时候,可以从某个现有的class继承,新的class称为子类(Subclass),而被继承的class称为基类.父类或超类 ...