In a recent project, I need to implement a mini-toolbar (floating, no windows title bar, no close button), and it come immediately into my mind: why not using a context menu to implement this?
I then added below xaml code, and changed the heading text to tooltip:
Running the above code, and not surprisingly, I go the below UI result:
To turn the vertical context menu into a horizontal one, we can add the below markup:
The result should look like this now:
Not bad! I then added “Width=24” to each menu item, to limit the padding area for each blank menu header. It looks better, but not perfect.
I then added a left margin to the 2nd menu item, so that the spacing between the context toolbar is more uniform:
Looks much nicer! Is it?
Now when we wish to make this context- or mini-toolbar visible, we can simply set its property menu.IsOpen = true, that is it!