Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to show MainMenu items in the ToolBar like Chart window?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to show MainMenu items in the ToolBar like Chart window?

    In custom add-on windows (derived from NTWindow), items added to the MainMenu collection get displayed in a Menu control. WPF wraps each item in a MenuItem for display, but this gives the items a horrible appearance when you hover over them:

    Click image for larger version

Name:	2024-11-27 12_34_15-Window.png
Views:	156
Size:	3.6 KB
ID:	1325853
    Click image for larger version

Name:	image.png
Views:	138
Size:	22.8 KB
ID:	1325854

    How can I display MainMenu items in the ToolBar like Chart window does?​

    Click image for larger version

Name:	image.png
Views:	133
Size:	20.9 KB
ID:	1325855

    Notice the Menu and ToolBar​ controls are both added and available in the custom add-on window and Chart window visual tree. The problem is the items in the MainMenu collection are bound to the Menu control in custom add-on window, but I want them bound and displayed in the ToolBar control like Chart window does.

    Ordinarily I would do this:

    Click image for larger version

Name:	image.png
Views:	135
Size:	28.0 KB
ID:	1325856

    But this.FindFirst("PART_Menu") always returns null. How can I get a reference to the Menu control so I can hide it?

    ​​

    #2
    Hello tcdouglas,

    While I wouldn't know how to collapse the menu as it cannot be found using the FindFirst method it does look like you are adding items to the menu instead of the toolbar which would cause a difference. Have you tried using the variable for the toolbar that you found to add items to that directly?

    Comment


      #3
      I've just solved it: the ToolBar control (which can be found through it's automation id) is hosted in the same Grid panel as the Menu control (which cannot be found via it's automation id).

      So I can do this to display MainMenu items in the ToolBar instead of the Menu:​

      Click image for larger version

Name:	image.png
Views:	122
Size:	40.2 KB
ID:	1326226

      This gives identical appearance to the NT Chart window:

      Click image for larger version  Name:	image.png Views:	0 Size:	7.4 KB ID:	1325874​​
      Last edited by tcdouglas; 11-30-2024, 03:46 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      32 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      127 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      182 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      94 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      138 views
      0 likes
      Last Post cmoran13  
      Working...
      X