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:	162
Size:	3.6 KB
ID:	1325853
    Click image for larger version

Name:	image.png
Views:	143
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:	138
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:	140
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:	129
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 DannyP96, 05-18-2026, 02:38 PM
      1 response
      85 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      143 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      83 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      256 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      334 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X