WPF 工具提示样式 [英] WPF ToolTip Style
本文介绍了WPF 工具提示样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 ToggleButton
和 ToolTip
,ToolTip
的内容与 Text
属性绑定.现在我需要在 ToggleButton
中设置我的 ToolTip
样式.我知道它不允许我在 ToggleButton
中为 ToolTip
应用样式,但我不知道该怎么做.
I have one ToggleButton
with ToolTip
, content of ToolTip
is bind with Text
property. Now I need to style my ToolTip
within ToggleButton
. I know its not allow me apply style within ToggleButton
for ToolTip
and I don't know how to do it.
这是我的代码的样子:
<ToggleButton
x:Name="btn"
Margin="10,0,0,20"
Style="{StaticResource bubbleStyle}"
ToolTip="{Binding ElementName=tbText, Path=Text, Mode=TwoWay}" />
推荐答案
如果我正确理解您的问题,您想在 ToggleButton
中为 ToolTip
定义样式.
If I understand your question correctly, you want to define a style for ToolTip
within your ToggleButton
.
试试这个:
<ToggleButton Content="ON" Grid.Row="1" ToolTip="{Binding ElementName=tbText, Path=Text}">
<ToggleButton.Resources>
<Style TargetType="ToolTip" BasedOn="{StaticResource {x:Type ToolTip}}">
<Setter Property="Background" Value="Red" />
</Style>
</ToggleButton.Resources>
</ToggleButton>
这篇关于WPF 工具提示样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文