最佳答案
我试图显示一个工具提示,而不考虑按钮的状态,但这似乎不起作用:
<Button Command="{Binding Path=CommandExecuteAction}"
ToolTip="{Binding Path=Description}" ToolTipService.ShowOnDisabled="true"
Style="{StaticResource toolbarButton}">
<Image Source="{Binding Path=Icon}"></Image>
</Button>
当按钮因Command.CanExecute返回false而被禁用时,如何显示工具提示?
注意:
ToolTipService.ShowOnDisabled=“ true ”非常有效。这在我的示例中不起作用的原因是,与按钮关联的样式重新定义了ControlTemplate,并在按钮被禁用时关闭了对按钮的点击测试(ishItTestVisible=false)。在ControlTemplate中重新启用点击测试可在禁用按钮时显示工具提示。