【Tooltip】WPF中Tooltip使用技巧总结

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

【Tooltip】WPF中Tooltip使⽤技巧总结
1. 简单⽰例——包含两个TextBlock:
代码
<Button Content="Tooltip演⽰">
<Button.ToolTip>
<ToolTip>
<StackPanel>
<TextBlock FontWeight="Heavy">两个TextBlock</TextBlock>
<TextBlock>简要介绍:Tooltip是⼀个⼗分强⼤的功能组件!</TextBlock>
</StackPanel>
</ToolTip>
</Button.ToolTip>
</Button>
效果如下:
2. 控件禁⽤时显⽰⽰例:
<Button Content="禁⽤控件Tooltip演⽰" IsEnabled="False" ToolTip="禁⽤按钮" ToolTipService.ShowOnDisabled="True"/>
3. 设定显⽰时长:
ToolTipService.ShowDuration="5000"
Tooltip将显⽰5秒钟。

4. 简单组合演⽰:
代码
<Button Content="丰富多彩的Tooltip">
<Button.ToolTip>
<StackPanel Background="Azure" Height="200" Width="200">
<StackPanel Background="LightBlue" Height="30" Width="200" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top"> <Image VerticalAlignment="Top" Width="30" Height="30" Source="Images\qianqian.png"/>
<TextBlock>
<Run FontFamily="微软雅⿊" FontSize="18" FontWeight="Normal" Text="天使的翅膀"/>
</TextBlock>
</StackPanel>
<StackPanel Width="200">
<TextBlock TextWrapping="Wrap" Width="100" Height="98" HorizontalAlignment="Center" VerticalAlignment="Top">
<Run FontFamily="Verdana" FontSize="11" Foreground="Black" Text="落叶随风将要去何⽅只留给天空美丽场"/>
</TextBlock>
</StackPanel>
</StackPanel>
</Button.ToolTip>
</Button>
效果如下:
5. 简单带阴影效果Tooltip:
代码
<Button Width="120" Height="30" Content="带阴效果Tooltip">
<Button.ToolTip>
<Border Background="LightBlue" Margin="-4,0,-4,-3">
<Border.BitmapEffect>
<OuterGlowBitmapEffect></OuterGlowBitmapEffect>
</Border.BitmapEffect>
<Label>简单带阴影效果Tooltip</Label>
</Border>
</Button.ToolTip>
</Button>
实现效果如下:
扩展阅读:
1. How to: Position a ToolTip:
参考API⽂档:。

相关文档
最新文档