tags:

views:

302

answers:

4
+2  Q: 

Key Tips in WPF

+1  A: 

First, you could check out the Ribbon Preview in the WPF Toolkit by Microsoft.

Or, one general approach would be like this:

  1. Make a DependencyProperty in your Window / top-level control that you can trigger off of, like IsShowingKeyTips. Catch keyboard input to flip this as you deem appropriate.

  2. Make a ContentControl that has two dependency properties like 1) IsShowingKeyTip and 2) KeyTipText. Let's call this KeyTipContentControl.

  3. Edit the ContentControl's ControlTemplate to look how you want. Make it a Canvas or your favorite layout container, use some bindings to size it properly, maybe throw in some negative Margin values.

  4. If you want to be fancy, make some AttachedProperties like KeyTip.Text to bubble them up from the plain control to the KeyTipContentControl.

  5. In your XAML, put the ContentControls around the Controls 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. :-)

GreenReign
A: 

plz write full code not working i m just a beginer in wpf

+2  A: 

Just use Fluent Ribbon Control Suite (it's free & supports all required features)

daVinci
Thanks for the link! Note that the question wasn't about which Ribbon to use, but in fact how to create KeyTips (specifically separate from any ribbon implementation). That said, this is an open source implementation of KeyTips, and for that reason, this is a useful answer.
Brad Leach
+1  A: 

Also, you can find helpful this walkthrough.

daVinci