Wpf 在VB.Net中向启用/禁用的图片控件添加工具提示?
我需要有一个图像的工具提示,基于它是否启用。现在我只能让它在启用时使用静态工具提示。如果禁用,如何使其显示不同的工具提示Wpf 在VB.Net中向启用/禁用的图片控件添加工具提示?,wpf,vb.net,xaml,Wpf,Vb.net,Xaml,我需要有一个图像的工具提示,基于它是否启用。现在我只能让它在启用时使用静态工具提示。如果禁用,如何使其显示不同的工具提示 <Button x:Name="Button" Width="21" Height="21" Padding="1,1,2,1" BorderThickness="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Background="DarkGray"> <Image
<Button x:Name="Button" Width="21" Height="21" Padding="1,1,2,1" BorderThickness="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Background="DarkGray">
<Image Source="../../Images/report.png" Stretch="Fill" HorizontalAlignment="Center" Height="20" Width="20" Margin="0,0,0,0" />
</Button>
使用并在XAML中完成所有操作:
<Button x:Name="Button" Width="21" Height="21" Padding="1,1,2,1" BorderThickness="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Background="DarkGray" ToolTipService.ShowOnDisabled="True">
<Button.Style>
<Style TargetType="Button">
<Setter Property="ToolTip" Value="Reports"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="ToolTip" Value="Please select a Transmittal"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Image Source="../../Images/report.png" Stretch="Fill" HorizontalAlignment="Center" Height="20" Width="20" Margin="0,0,0,0" />
</Button>
注意:您必须删除用于设置工具提示的现有代码,否则它将覆盖此代码。使用并在XAML中完成所有操作:
<Button x:Name="Button" Width="21" Height="21" Padding="1,1,2,1" BorderThickness="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" Background="DarkGray" ToolTipService.ShowOnDisabled="True">
<Button.Style>
<Style TargetType="Button">
<Setter Property="ToolTip" Value="Reports"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="ToolTip" Value="Please select a Transmittal"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Image Source="../../Images/report.png" Stretch="Fill" HorizontalAlignment="Center" Height="20" Width="20" Margin="0,0,0,0" />
</Button>
注意:您必须删除设置工具提示的现有代码,否则它将覆盖此代码。我认为未启用的按钮不能显示工具提示。@Mary很好,您需要添加ToolTipService.ShowOnDisabled=True才能工作。我已经更新了我的答案。我认为未启用的按钮不能显示工具提示。@Mary很好,您需要添加ToolTipService.ShowOnDisabled=True才能工作。我已经更新了我的答案。