按钮上的工具提示

时间:2014-08-16 07:42:26

标签: wpf xaml wpf-controls

我正在尝试根据图像选择在按钮上设置工具提示,如下面的代码所示。我想基于Image设置工具提示如果按钮显示正常图像我想将工具提示设置为" Active"如果显示鼠标悬停图像,则工具提示应为"非活动"。我可以毫无问题地在主按钮上设置工具提示。图像显示正常,但我无法根据普通图像或悬停图像切换/显示工具提示。

NormalHoverImageButton

是标准按钮,包含两个DependencyProperties,用于保存普通图像,悬停图像为ImageSource。在xaml中有什么办法,我可以设置这个工具提示属性。

   <c:NormalHoverImageButton DockPanel.Dock="Left" 

   ToolTip="Display Tool Tip"                                                             
    NormalImage="{Binding Status, Converter={StaticResource NormalImageSourceConverter}}" 
    HoverImage="{StaticResource MouseHoverImage}" 
    Visibility="{Binding IsTestTrue, Converter={StaticResource MyVisibilityConverter}}">

  </c:NormalHoverImageButton>

1 个答案:

答案 0 :(得分:0)

尝试

ToolTip="{Binding RelativeSource={RelativeSource Self}, Path = NormalImage, Convertert={...}" 

转换器应该检查NormalImage是否为空。如果是这样,返回一种文本工具提示,否则另一种。如果有效,请告诉我。

相关问题