This is a migrated thread and some comments may be shown as answers.

Manually resize submenu

3 Answers 92 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 01 Mar 2021, 07:46 PM
We are looking for a way to manually resize the submenu for items that have a very large collection of menu items.  Sometimes, these lists are long enough that the submenu ends up taking up the entirety of the vertical space on screen, including the taskbar.  We'd like to limit the height of the submenus to the size of the current workspace, effectively allowing the panel to scroll more through the content and display less at a time.

A solution in xaml is not sufficient, as these submenus are dynamically populated in code.  We already have code set up to determine what we'd like to set the height of the submenu's panel to, but despite trying many ways of getting ahold of the correct components in code, we have been unable to successfully modify the submenu panel's height.

Anybody know of a good solution for this?

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 04 Mar 2021, 12:29 PM

Hello Chad,

Generally speaking, the menu items are displayed inside a Popup. With this in mind you will not be able to find their panel, if you are searching the visual tree inside the MainWindow (for example with the ChildrenOfType extensions). 

That said, you can extract and update the ControlTemplate of the RadMenu or RadMenuItem for the theme that you using and update the elements in it (for example setting their Height/MaxHeight). Can you give this approach a try and let me know, if it helps? 

If the above mentioned approach does not help, can you share some more information about your scenario? You can send over a picture of the current scenario and the expected result. You can also share some sample code demonstrating how the RadMenu is defined. This will hopefully allow me to get a better understanding of the scenario and further assist you. 

Regards,
Vladimir Stoyanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Chad
Top achievements
Rank 1
answered on 05 Mar 2021, 10:36 PM
Thank you for the quick reply.

I can provide a little more context for our particular scenario.
Occasionally, we have users that use 3rd party software to use our software remotely, so that they can use it from operating systems other than Windows.  In some of these situations, it would seem the size of the RadMenu will occasionally be larger than the viewed workspace.  We have surmised that this is also the reason why by default, the RadMenu will extend over the task bar even in a native windows environment.

By using the Windows API in code, we can get the actual workspace available (which excludes the task bar) and limit our UI elements to this available space.  However, so far, we have been unable to find a way to apply these limits to the RadMenu in code.  I fear the extracting the control template will not suffice, as it would require a hardcoded value when we'd like to be able to limit it variably based on the user's machine.

Does this help to explain the issue?  If not, I could perhaps look into finding a portion of our code that I would be allowed to share, it it would help.
0
Vladimir Stoyanov
Telerik team
answered on 10 Mar 2021, 02:23 PM

Hello Chad,

Thank you for the additional information. 

What comes to mind based on the shared details is handling the SubmenuOpened event of the RadMenuItems and setting the size of its child Popup element.

Please, find a sample project demonstrating this approach for your reference. Of course, feel free to adapt it in order to suit your exact scenario. 

Regards,
Vladimir Stoyanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Menu
Asked by
Chad
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Chad
Top achievements
Rank 1
Share this question
or