FlorianStruck
asked on
Creating a flexible Context Menu
I would like to have a context menu which I can setup and open from basically anywhere in my C# code, so it should not be bound to a 'context' like a button or textbox.
My first idea was to use a window and apply a similar behaviour to it, like when clicking on the main window it closes. Would that be an option?
I've only found samples like this, where it's bound to a text box.
<TextBox Text="Text" Margin="25">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="MenuItem1">Menu Entry</MenuItem>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
My first idea was to use a window and apply a similar behaviour to it, like when clicking on the main window it closes. Would that be an option?
I've only found samples like this, where it's bound to a text box.
<TextBox Text="Text" Margin="25">
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="MenuItem1">Menu Entry</MenuItem>
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to be of help.
ASKER
To create, setup and open a ContextMenu in C# Code some information can be found here.
http://evgenya.wordpress.com/2008/04/14/wpf-building-contextmenu-on-fly