<?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: stuck in Ribbonbutton.CommandHander , i have created wpf UI in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243495#M1276</link>
    <description>&lt;P&gt;Are you familiar with how to create a Window like the one you show?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to create an instance of the Window and pass it as the argument to ShowModalWindow().&lt;/P&gt;</description>
    <pubDate>Sun, 05 Jan 2025 13:43:00 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2025-01-05T13:43:00Z</dc:date>
    <item>
      <title>stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243474#M1274</link>
      <description>&lt;LI-CODE lang="general"&gt;using Autodesk.AutoCAD.ApplicationServices;
using System;
using System.Windows.Controls.Ribbon;
using System.Windows.Input;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace LabelsCross
{
    public class RibbonCommandHandler : ICommand
    {
        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;

            if (parameter is RibbonButton)
            {// here what i neeed do
                Application.ShowModelessWindow(?);
            }
        }
    }
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 05 Jan 2025 13:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243474#M1274</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-05T13:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243476#M1275</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AravinthPichamani_0-1736083780637.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1451233iA1CC870A14084351/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AravinthPichamani_0-1736083780637.png" alt="AravinthPichamani_0-1736083780637.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;this my WPF code&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 13:29:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243476#M1275</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-05T13:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243495#M1276</link>
      <description>&lt;P&gt;Are you familiar with how to create a Window like the one you show?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to create an instance of the Window and pass it as the argument to ShowModalWindow().&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 13:43:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243495#M1276</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-01-05T13:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243515#M1277</link>
      <description>&lt;P&gt;I'm familiar with WPF. I'm created above show picture. But when I'm clicking button not showing windows (wpf)&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 14:10:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243515#M1277</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-05T14:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243783#M1278</link>
      <description>&lt;P&gt;You are not showing the relevant code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code you showed you have a question mark as the argument. What are you passing as that argument?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 17:33:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243783#M1278</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-01-05T17:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243806#M1279</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12423358"&gt;@Aravinth.Pichamani&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm familiar with WPF. I'm created above show picture. But when I'm&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt; clicking button&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt; not showing windows (wpf)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which button you click? Since you showed the code of RibbonCommandHandler, I assume the RibbonCommandHandler is SUPPOSED to be assigned to a RibbonCommandItem (typically a RibbonButton) created by your code. So, does your code creates a such RibbonCommandItem? If yes, show the code. If not, I do not see the code of RibbonCommandHandler is relevent when it is not used anywhere. It might be too much for someone who is not yet very familiar to AutoCAD .NET API programming to figure out how to create a RibbonCommandItem in order to just show an UI in AutoCAD. You should begin with creating a simply CommandMethod to show either "Hello AutoCAD" at command line, or show a UI:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[CommandMethod("ShowMyUI")]&lt;/P&gt;
&lt;P&gt;public static void ShowMyMainWindow()&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var win=new MainWindow()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;win.DataContext=MyMainViewModel;&amp;nbsp; // If you do know WPF well, you should do MVVM&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var result = Application.ShowModalWindow(win);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if (result.HasValue &amp;amp;&amp;amp; result.Value)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // If the modal UI is oked by user&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // you might want to do something based on the user inputs in the UI&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;With this command "ShowMyUI" available, and you indeed created a RibbonCommandItem, which is assigned the RibbonCommandHandler, then you can set the RibbonCommandItem's CommandParameter property with this command, like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MyRibbonButton.CommandHandler = RibbonCommandHandler;&lt;/P&gt;
&lt;P&gt;MyRibbonButton.CommandParameter = "ShowMyUI ";&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in the RibbonCommandHandler, you can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;   ...
        public void Execute(object parameter)
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;

            if (parameter is RibbonButton)
            {
                var commandString=((RibbonButton)parameter).CommandParameter.ToString();
                var dwg=Application.DocumentManager.MdiActiveDocument;
                if (dwg != null)
                {
                   dwg.SendStringToExecute(commandString, true, false, false);
                }
            }
        }
   ...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 15:48:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13243806#M1279</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2025-01-06T15:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13244256#M1280</link>
      <description>&lt;LI-CODE lang="general"&gt;    public class EApplication : IExtensionApplication
    {

        public static class Images
        {
            public static BitmapImage GetBitmap(string path)
            {
                BitmapImage bmp = new BitmapImage();
                bmp.BeginInit();
                bmp.UriSource = new Uri(path);
                bmp.EndInit();
                return bmp;
            }
        }
        
        public static void CreateRibbonbtn()
        {
            RibbonControl ribbon = ComponentManager.Ribbon;

            RibbonTab tab = new RibbonTab();

            // setting the name for the tab
            tab.Title = " LD &amp;amp; ME";
            // settting the id for the tab
            tab.Id = "LD";

            ribbon.Tabs.Add(tab);

            // creating a new panelsource for the tab

            RibbonPanelSource panelSource = new RibbonPanelSource();
            panelSource.Title = "Label";

            // creating a panel from the source 

            RibbonPanel panell = new RibbonPanel();
            panell.Source = panelSource;

            // adding the panel to the tabs we created 
            tab.Panels.Add(panell);

            //creating a button for the panel we have created

            try 
            {
                RibbonButton btn = new RibbonButton();
                btn.Text = "Lable";
                btn.ShowText = false;
                btn.CommandParameter = "";
                btn.ShowImage = true;
                btn.Image = Images.GetBitmap(@"C:\WSP\code\civil 3d c#\LabelsCross\LabelsCross\Resources\pipe.png");
                btn.Orientation = System.Windows.Controls.Orientation.Vertical;
                btn.CommandHandler = new RibbonCommandHandler();
                panelSource.Items.Add(btn);
                btn.Size = (RibbonItemSize)250;
            }

            catch (System.Exception ex) 
            {
                Application.ShowAlertDialog(ex.Message);
            }
       
           
        
        }

        public void Initialize()
        {
            CreateRibbonbtn();
            //throw new NotImplementedException();
        }

        public void Terminate()
        {
            //throw new NotImplementedException();
        }
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Jan 2025 03:47:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13244256#M1280</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-06T03:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13244276#M1281</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AravinthPichamani_0-1736135414247.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1451351i03E0763124CB5E7B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AravinthPichamani_0-1736135414247.png" alt="AravinthPichamani_0-1736135414247.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Yuan, I created my first button and WPF UI. Next, I need to develop the MVVM pattern. Above, I pasted the ribbon button code. Could you please help me? when I'm clicking that button window not showing.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 03:55:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13244276#M1281</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-06T03:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245546#M1282</link>
      <description>&lt;P&gt;If you read my reply carefully, you should have seen this&lt;/P&gt;
&lt;P&gt;&amp;lt;QUOTE&amp;gt;&lt;/P&gt;
&lt;P&gt;With this command "ShowMyUI" available, and you indeed created a RibbonCommandItem, which is assigned the RibbonCommandHandler, then you can set the RibbonCommandItem's CommandParameter property with this command, like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MyRibbonButton.CommandHandler = RibbonCommandHandler;&lt;/P&gt;
&lt;P&gt;MyRibbonButton.CommandParameter = "ShowMyUI ";&lt;/P&gt;
&lt;P&gt;&amp;lt;/QUOTE&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is, in your code, simply add 1 line code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;            try 
            {
                RibbonButton btn = new RibbonButton();
                btn.Text = "Lable";
                btn.ShowText = false;
                btn.CommandParameter = "";
                btn.ShowImage = true;
                btn.Image = Images.GetBitmap(@"C:\WSP\code\civil 3d c#\LabelsCross\LabelsCross\Resources\pipe.png");
                btn.Orientation = System.Windows.Controls.Orientation.Vertical;
                btn.CommandHandler = new RibbonCommandHandler();
                // Set CommandParameter to an existing command,
                // be it a built-in one, or your own command
                btn.CommandParameter = "ShowMyUI " 
                panelSource.Items.Add(btn);
                btn.Size = (RibbonItemSize)250;
            }

            catch (System.Exception ex) 
            {
                Application.ShowAlertDialog(ex.Message);
            }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, you need to update your RibbonCommandHandler code as I showed in my previous reply and you would have a CommandMethod that defines the corresponding command "ShowMyUI", also showed in my previous reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I assume your code is just concept-proving code. That is, in real world, you would not run the CreateRibbonBtn() method directly in the IExtensionApplication.Intialize(). This has been discussed in this forum many times, years. You can search "Ribbon" in this forum for the past discussion, and especially pay attention to the answers provided by&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 15:54:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245546#M1282</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2025-01-06T15:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245562#M1283</link>
      <description>&lt;P&gt;Hi yuan i tried what you are showing the code still not working&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 15:53:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245562#M1283</guid>
      <dc:creator>Aravinth.Pichamani</dc:creator>
      <dc:date>2025-01-06T15:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in Ribbonbutton.CommandHander , i have created wpf UI</title>
      <link>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245590#M1284</link>
      <description>&lt;P&gt;There is nothing I can tell without see all the code. I only know you have a RibbonButton available. So, the first question is: did you debug the ribbonbutton click by placing a break point in the RibbonCommandHandler? If the break point is hit, you should clearly see what the issue is, such as whether the command assigned to the CommandParameter is executed by Document.SendStringToExecute().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 16:04:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/stuck-in-ribbonbutton-commandhander-i-have-created-wpf-ui/m-p/13245590#M1284</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2025-01-06T16:04:24Z</dc:date>
    </item>
  </channel>
</rss>

