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">
                  <MenuItem x:Name="MenuItem1">Menu Entry</MenuItem>
Who is Participating?
Dennis AriesConnect With a Mentor CEO @ Arkro ITCommented:
You will have to create the contextmenu as a resource. has good example of that.
FlorianStruckAuthor Commented:
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.
Dennis AriesCEO @ Arkro ITCommented:
Glad to be of help.
All Courses

From novice to tech pro — start learning today.