我已将以下控件模板和样式设置为应用程序中所有工具提示的默认样式:
<Style TargetType="{x:Type ToolTip}">
<!-- Background="Transparent" BorderBrush="Transparent" BorderThickness="0" HasDropShadow="True" -->
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Placement" Value="Bottom"></Setter>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="{Binding Source={x:Static visualResources:ThemeManager.Instance}, Path=ThemePageColor}" >
<ContentPresenter Margin="3"></ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
(上面的代码在Window.Resources中)
在同一窗口中,我具有以下控件:
<Button ToolTip="Tooltip Text!" HorizontalContentAlignment="Right" Height="60" Click="_Button_AddCourse_Click"/>
但是,当我运行我的程序时,工具提示并没有出现应有的提示!我只能看到一个橙色矩形(它是controltemplate中的Grid,橙色是ThemeManager.Instance.ThemePageColor属性),但是工具提示中没有文本。
提前致谢。
抱歉,我正在急忙尝试通过我的手机执行此操作,然后将其错误地放入了评论中。
无论如何,只要更改<ControlTemplate>
为<ControlTemplate TargetType="ToolTip">
,它就会知道您ContentPresenter
甚至想和谁说话,并且您应该很好。
希望这会有所帮助,加油!
PS-Mark这样回答了问题,所以人们知道您已解决问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句