First, you could check out the Ribbon Preview in the WPF Toolkit by Microsoft.
Or, one general approach would be like this:
Make a
DependencyProperty
in your Window / top-level control that you can trigger off of, likeIsShowingKeyTips
. Catch keyboard input to flip this as you deem appropriate.Make a
ContentControl
that has two dependency properties like 1)IsShowingKeyTip
and 2)KeyTipText
. Let's call thisKeyTipContentControl
.Edit the
ContentControl
'sControlTemplate
to look how you want. Make it aCanvas
or your favorite layout container, use some bindings to size it properly, maybe throw in some negativeMargin
values.If you want to be fancy, make some
AttachedProperties
likeKeyTip.Text
to bubble them up from the plain control to theKeyTipContentControl
.In your XAML, put the
ContentControls
around theControls
you want the KeyTips on. Set the bindings as appropriate.
You'll end up with something like this at the top level:
<Window ... >
<code:KeyTipContentControl
KeyTipText="A"
IsShowingKeyTip="{Binding IsShowingKeyTips}">
<Button x:Name="MyButtonWithKeyTip" ... />
</code:KeyTipContentControl>
</Window>
To handle the key press in an elegant fashion is not something I'm up for right now. :-)