<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Show a WPF window in the center of the AutoCAD window in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/show-a-wpf-window-in-the-center-of-the-autocad-window/m-p/8242087#M24889</link>
    <description>&lt;P&gt;How do you show the window (with your code)? Does the window show as Modal, or as Modeless?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether you use Win Form or WPF, DO NOT use Form/Window.Show()/ShowDialog() to show the form/window in AutoCAD. Use AutoCAD .NET API's ShowModal[Modeless]Dialog[Window]() method, which has various overloads, where you can pass AutoCAD window's handle as your form/window's owner; you can also pass a parameter to let AutoCAD to remember the form/windows previous location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it would be as simple as:&lt;/P&gt;
&lt;PRE&gt;            var dialog = new MyWpfWindow();
            Application.ShowModalWindow(Application.MainWindow.Handle, dialog, false);
            dialog.Close();&lt;/PRE&gt;
&lt;P&gt;In this code, the Window's startup location is set to OwnerCenter. and the last parameter passed on ShowModalWindow() is false, meaning AutoCAD does not remember the previous location (thus does not try to place the form/window is previous location).&lt;/P&gt;</description>
    <pubDate>Mon, 03 Sep 2018 16:57:43 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2018-09-03T16:57:43Z</dc:date>
    <item>
      <title>Show a WPF window in the center of the AutoCAD window</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-a-wpf-window-in-the-center-of-the-autocad-window/m-p/8241703#M24888</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I show a WPF window in the center of the main AutoCAD window?&lt;/P&gt;&lt;P&gt;I set a property &lt;EM&gt;WindowStartupLocation&lt;/EM&gt; of my window&amp;nbsp; to &lt;EM&gt;CenterOwner. &lt;/EM&gt;But how can I set the main AutoCAD window as an owner of the window (there is an&amp;nbsp;&lt;EM&gt;Owner&lt;/EM&gt; property, but its type is &lt;EM&gt;System.Windows.Window&lt;/EM&gt;)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 12:47:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-a-wpf-window-in-the-center-of-the-autocad-window/m-p/8241703#M24888</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-03T12:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Show a WPF window in the center of the AutoCAD window</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-a-wpf-window-in-the-center-of-the-autocad-window/m-p/8242087#M24889</link>
      <description>&lt;P&gt;How do you show the window (with your code)? Does the window show as Modal, or as Modeless?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether you use Win Form or WPF, DO NOT use Form/Window.Show()/ShowDialog() to show the form/window in AutoCAD. Use AutoCAD .NET API's ShowModal[Modeless]Dialog[Window]() method, which has various overloads, where you can pass AutoCAD window's handle as your form/window's owner; you can also pass a parameter to let AutoCAD to remember the form/windows previous location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it would be as simple as:&lt;/P&gt;
&lt;PRE&gt;            var dialog = new MyWpfWindow();
            Application.ShowModalWindow(Application.MainWindow.Handle, dialog, false);
            dialog.Close();&lt;/PRE&gt;
&lt;P&gt;In this code, the Window's startup location is set to OwnerCenter. and the last parameter passed on ShowModalWindow() is false, meaning AutoCAD does not remember the previous location (thus does not try to place the form/window is previous location).&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 16:57:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-a-wpf-window-in-the-center-of-the-autocad-window/m-p/8242087#M24889</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-09-03T16:57:43Z</dc:date>
    </item>
  </channel>
</rss>

