Adding Context menu to TreeviewItem
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:
Thank you
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.
Thank you
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Adding Context menu to TreeviewItem
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?
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?
Re: Adding Context menu to TreeviewItem
Thank you for looking into that. The issue has been submitted to the tracker under ticket #2431.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Adding Context menu to TreeviewItem
Thanks for the report.
Who is online
Users browsing this forum: Google [Bot] and 90 guests