#858 – How to Set Properties for a Tooltip

There are basically three different ways to specify tooltips.  The first is to just set the Tooltip property on the control where the tooltip should appear.  You set the property to the text that you want to see in the tooltip.

        <Button Content="Read a Book"
                Padding="10,5" HorizontalAlignment="Center"
                ToolTip="You might start with Charles Dickens"/>

858-001
If you want to create a more complex tooltip, you can use the property element syntax.

        <Button Content="Read a Book"
                Padding="10,5" HorizontalAlignment="Center">
            <Button.ToolTip>
                <StackPanel>
                    <TextBlock Text="Reading Suggestion" FontWeight="Bold"/>
                    <TextBlock Text="Charles Dickens" Margin="5"/>
                </StackPanel>
            </Button.ToolTip>
        </Button>

858-002
Finally, if you want to specify property values for the ToolTip, you can use a ToolTip element.

        <Button Content="Read a Book"
                    Padding="10,5" HorizontalAlignment="Center">
            <Button.ToolTip>
                <ToolTip Foreground="Blue">
                    <StackPanel>
                        <TextBlock Text="Reading Suggestion" FontWeight="Bold"/>
                        <TextBlock Text="Charles Dickens" Margin="5"/>
                    </StackPanel>
                </ToolTip>
            </Button.ToolTip>
        </Button>

858-003