Is there any way to trigger if an item is right clicked? I would like to show my own context-menu in this case but I find no way to detect the right click. ItemClick does not work for the right mouse button. So I could use MouseClick, but I don't find a way to check if the mouse location is within an item or not..
Or is it preferred to modify the default context menu to fit my needs?
Thanks,Stefan
Edit: I just found the function ItemFromPoint() which works fine. Now I only have problems when showing a context-menu for a group. GroupFromPoint() returns the group when I click on an empty place within a group and therefor the menu will be shown. I would like to restrict this to the group header only. When I use the GroupClick event it is only fired when I click on the group itself, this would be the desired way..
I just use the context menu to open a openfiledialog where the user can select an icon that is shown for the clicked item or group..
ItemFromPoint/GroupFromPoint don't tell you what part of the item/group was clicked, so you would have to manually hit test for the constituent part you are looking for:
void ultraExplorerBar1_MouseDown(object sender, MouseEventArgs e){ UltraExplorerBar explorerBar = sender as UltraExplorerBar; UIElement controlElement = explorerBar.UIElement; UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null;
while ( elementAtPoint != null ) { UltraExplorerBarGroupHeaderUIElement headerElement = elementAtPoint as UltraExplorerBarGroupHeaderUIElement;
if ( headerElement != null ) { UltraExplorerBarGroup group = headerElement.Group; }
elementAtPoint = elementAtPoint.Parent; }}
Thanks for your help. This is the desired way to check if a group was right clicked.