Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Thursday, June 28, 2012

ToolTips in WPF

ToolTips in WPF

 
<Button Content="Submit">
    <Button.ToolTip>
        <ToolTip>
            <StackPanel>
                <TextBlock FontWeight="Bold">Submit Request</TextBlock>
                <TextBlock>Submits the request to the server.</TextBlock>
            </StackPanel>
        </ToolTip>
    </Button.ToolTip>
</Button>
 
 

How to show ToolTips on disabled controls

When you disable a control with IsEnabled=False the tooltip does not show anymore. If you want to have the tooltip appear anyway you have to set the attaached property ToolTipService.ShowOnDisabled to True.
 
<Button IsEnabled="False" 
        ToolTip="Saves the current document"
        ToolTipService.ShowOnDisabled="True"
        Content="Save">
</Button>
 
 

How to change the show duration of a ToolTip

The static class ToolTipService allows you to modify the show duration of the tooltip
 
<Button ToolTip="Saves the current document"
        ToolTipService.ShowDuration="20"
        Content="Save">
</Button>

No comments:

Post a Comment