i must confess i couldn't find a better title.
I have a Control which contains in the lower part a TextBox. This control has a ContextMenu and of course the TextBox has its normal text editing ContextMenu. When i right click the outer control its ContextMenu opens, which is what i want. If i right click the textbox it gets the focus and opens it text editing context menu. But when i right click the textbox and it doesn't has the keyboard focus i don't want the focus set and don't want to open the textbox contextmenu, instead it should open the outer control contextmenu.
The only thing i managed was to ignore the contextmenu of the textbox, when right clicking the textbox. (for testing i created a control derived from TextBox)
protected override void OnMouseDown(MouseButtonEventArgs aArgs)
{
if(aArgs.ChangedButton == MouseButton.Right)
{
return;
}
base.OnMouseDown(aArgs);
}
Even doing this, the textboxes OnContextMenuOpening gets fired but no matter if handled is true or false, no context menu at all opens.
I hope someone has an idea.
PreviewMouseDowninstead ofMouseDown? - Rachel