Link to home
Start Free TrialLog in
Avatar of FlorianStruck
FlorianStruckFlag for Germany

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>
ASKER CERTIFIED SOLUTION
Avatar of Dennis Aries
Dennis Aries
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FlorianStruck

ASKER

Thanks. You did point me into the right direction.

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
Glad to be of help.