在我的WPF应用程序中,Toolbar中以下XAML
的{{1}}按钮显示ToolTip
,而不是Paste
按钮显示。 问题:为什么会发生这种情况,我们如何解决?
Copy
答案 0 :(得分:1)
要显示命令绑定按钮的工具提示,请设置 ToolTipService.ShowOnDisabled =“ True”
<DockPanel Name="mainPanel" VerticalAlignment="Top">
<ToolBar Name="mainToolBar" Height="30" DockPanel.Dock="Top">
<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Copy" ToolTip="Copy" ToolTipService.ShowOnDisabled="True">
<Image Source="C:\Users\mcpl\Documents\Visual Studio 2015\Projects\TestApplication\TestApplication\Images\Add.png"></Image>
</Button>
<Button Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Paste" ToolTip="Paste" ToolTipService.ShowOnDisabled="True">
<Image Source="C:\Users\mcpl\Documents\Visual Studio 2015\Projects\TestApplication\TestApplication\Images\edit.png"></Image>
</Button>
</ToolBar>
答案 1 :(得分:0)
尝试使用CommandBinding
<ToolBar Name="mainToolBar" Height="30" DockPanel.Dock="Top">
<Button Style="{StaticResource formatImageStyle}" ToolTip="Copy">
<Button.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" />
</Button.CommandBindings>
<Image Source="C:\Users\heruvath\Desktop\user-48.png"></Image>
</Button>
<Button Style="{StaticResource formatImageStyle}" ToolTip="Paste">
<Button.CommandBindings>
<CommandBinding Command="ApplicationCommands.Paste" />
</Button.CommandBindings>
<Image Source="C:\Users\heruvath\Desktop\user-48.png"></Image>
</Button>
</ToolBar>