<?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: WPF - MVVM : prevent multiple calls of Dialogs in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12366530#M6672</link>
    <description>&lt;P&gt;Using modeless dialog/window/PalleteSet is tricky.&lt;/P&gt;
&lt;P&gt;Typically, it should be instantiated as singleton object in an AutoCAD session, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class MyCommandClass&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;private static MyWindow _window=null&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;[CommandMethod("ShowMyWindow", CommandFlags.Session)]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;publci static void ShowMyWindow()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; If (_window==null)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_window=new MyWindow();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Application.ShowModelessWindow(_window);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, you would want to handle Window.Closing event, where you cancel the closing and set its Visibility property to Hidden.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is, one the window is instantiated, it stays in the AutoCAD session, being either hidden or visible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, id the content of the window is drawing specific, you need to reset the content whenever current drawing changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also instantiate the modeless window on "per-document" basis (you could take advantage of [PerDocumentClass].&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These old articles might be of help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2014/02/showing-and-closing-modeless-formdialog.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2014/02/showing-and-closing-modeless-formdialog.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2018/09/showing-modeless-form-with-help-of.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2018/09/showing-modeless-form-with-help-of.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you use MVVM pattern, you can let the ViewModel to subcribe DocumentBecameCurrent event and update the ViewModel, which in turn update the window view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 17:56:05 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2023-11-09T17:56:05Z</dc:date>
    <item>
      <title>WPF - MVVM : prevent multiple calls of Dialogs</title>
      <link>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12365913#M6671</link>
      <description>&lt;P&gt;&lt;SPAN&gt;How can I prevent a modeless dialog created as WPF from being called again until it has been closed?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:40:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12365913#M6671</guid>
      <dc:creator>melomayo6BC8R</dc:creator>
      <dc:date>2023-11-09T14:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - MVVM : prevent multiple calls of Dialogs</title>
      <link>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12366530#M6672</link>
      <description>&lt;P&gt;Using modeless dialog/window/PalleteSet is tricky.&lt;/P&gt;
&lt;P&gt;Typically, it should be instantiated as singleton object in an AutoCAD session, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class MyCommandClass&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;private static MyWindow _window=null&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;[CommandMethod("ShowMyWindow", CommandFlags.Session)]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;publci static void ShowMyWindow()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; If (_window==null)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_window=new MyWindow();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Application.ShowModelessWindow(_window);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, you would want to handle Window.Closing event, where you cancel the closing and set its Visibility property to Hidden.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is, one the window is instantiated, it stays in the AutoCAD session, being either hidden or visible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, id the content of the window is drawing specific, you need to reset the content whenever current drawing changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also instantiate the modeless window on "per-document" basis (you could take advantage of [PerDocumentClass].&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These old articles might be of help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2014/02/showing-and-closing-modeless-formdialog.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2014/02/showing-and-closing-modeless-formdialog.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://drive-cad-with-code.blogspot.com/2018/09/showing-modeless-form-with-help-of.html" target="_blank" rel="noopener"&gt;https://drive-cad-with-code.blogspot.com/2018/09/showing-modeless-form-with-help-of.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you use MVVM pattern, you can let the ViewModel to subcribe DocumentBecameCurrent event and update the ViewModel, which in turn update the window view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 17:56:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12366530#M6672</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-11-09T17:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - MVVM : prevent multiple calls of Dialogs</title>
      <link>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12369649#M6673</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Norman,&lt;BR /&gt;many heartfelt thanks for that. Duplicate dialog calls are prevented by a static variable.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 20:39:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/wpf-mvvm-prevent-multiple-calls-of-dialogs/m-p/12369649#M6673</guid>
      <dc:creator>melomayo6BC8R</dc:creator>
      <dc:date>2023-11-10T20:39:45Z</dc:date>
    </item>
  </channel>
</rss>

