我試圖顯示工具提示,無論按鈕狀態,但這似乎並沒有這樣的伎倆:wpf:如何通過命令禁用按鈕時顯示工具提示?
<Button Command="{Binding Path=CommandExecuteAction}"
ToolTip="{Binding Path=Description}" ToolTipService.ShowOnDisabled="true"
Style="{StaticResource toolbarButton}">
<Image Source="{Binding Path=Icon}"></Image>
</Button>
我如何能顯示工具提示當按鈕被禁用由於command.CanExecute返回假?
注:
ToolTipService.ShowOnDisabled = 「真」 的作品就像一個魅力。這在我的例子中不起作用的原因是因爲與按鈕相關的樣式重新定義了控件模板,並且在按鈕被禁用時關閉了按鈕的命中測試(IsHitTestVisible = false)。在控制模板中重新啓用命中測試時,會在按鈕被禁用時顯示工具提示。
可能重複http://stackoverflow.com/questions/3149016/wpf-tooltip-visibility) – 2010-11-11 10:45:28
我正在使用ToolTipService.ShowOnDisabled,但它不起作用。 – Marius 2010-11-11 11:10:43
只需刪除此問題。我做了一個小測試項目,ToolTipService.ShowOnDisabled工作得很好。 – Marius 2010-11-11 11:33:54