RSS

Using context menu to mock WPF mini-toolbar (context toolbar)

15 Dec

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:

image

Running the above code, and not surprisingly, I go the below UI result:

image

To turn the vertical context menu into a horizontal one, we can add the below markup:

image

The result should look like this now:

image

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.

image

I then added a left margin to the 2nd menu item, so that the spacing between the context toolbar is more uniform:

image

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!

Advertisements
 
Leave a comment

Posted by on December 15, 2012 in General

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: