ZGholson
Topic Author
Posts: 9
Joined: 04 Aug 2022, 19:12

Adding Context menu to TreeviewItem

22 Sep 2022, 18:47

Hello,

We are looking at adding a context menu that works with controller to a TreeViewItem or the TreeView. The plan is to have the context menu open next to the item in the list and immediately take focus after we left click or press the select button on the TreeViewItem.

The two challenges are:
  • Copying the right click functionality to On Item Selected for controller
  • Opening the contextmenu next to the treeviewitem with focus.
Any suggestions are welcome here.

Thank you
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: Adding Context menu to TreeviewItem

23 Sep 2022, 21:06

Hi,

A ContextMenu can be manually open by setting the IsOpen property to true, so you can do that in response to a specific key/button in the gamepad (with a KeyTrigger/GamepadTrigger in xaml for example). And by setting ContextMenu's Placement="Right", it will be opened on the right of its owner (you can tweak the position adjusting the HorizontalOffset and VerticalOffset properties too). The ContextMenu could be defined as part of the TreeViewItem template or in one element of the HeaderTemplate.

Once the ContextMenu is opened it gets automatically focused and you should be able to navigate up and down through the items, but I found a bug in MenuItem code that breaks directional navigation when the menu is placed inside a ListBox or TreeView. Could you please report this in our bugtracker and we will fix it for the next release?
 
ZGholson
Topic Author
Posts: 9
Joined: 04 Aug 2022, 19:12

Re: Adding Context menu to TreeviewItem

23 Sep 2022, 23:22

Thank you for looking into that. The issue has been submitted to the tracker under ticket #2431.
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: Adding Context menu to TreeviewItem

27 Sep 2022, 11:38

Thanks for the report.

Who is online

Users browsing this forum: No registered users and 0 guests