Creating tooltips

Tooltips are typically those yellowish (or another color, depending on the Windows theme and user customization) pop ups that show up when the mouse pointer hovers over something important within the UI, providing some extra information relevant to that something. WPF makes it easy to create tooltips, either standard ones, or custom.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

  1. Create a new WPF application named CH04.ToolTips.
  2. Open MainWindow.xaml. Add two rows to the existing Grid as follows:
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
  3. Add a ToolBar to the Grid, with two buttons in it:
    <ToolBar> <Button Content="Copy" FontSize="16" Margin="4" Padding="4" ...

Get Windows Presentation Foundation 4.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.