[英]How do I make a tooltip displayw hen mouse cursor is over button in WPF
[英]How to make tooltip on hovering mouse over a button
我是c#silverlight(5)初学者,对如何制作工具提示一无所知。 实际上,我在工具箱中找不到工具提示的任何选项。
我要做的是在鼠标悬停按钮时显示工具提示。 假设我有这样的按钮:
<Button Content="{Binding Path=Id}"
Command="{Binding DataContext.ShowPopupCommand,
RelativeSource={RelativeSource AncestorType=data:DataGrid}}"/>
现在如何在ViewModel.cs类的此按钮上创建工具提示?
有人可以给我有关如何使用MVVM方法在c#silverlight应用程序中创建ToolTip的指导。 非常感谢您提供任何帮助的代码。 将会有很大的帮助。 谢谢。
<Button
ToolTipService.ToolTip="ToolTip based on the mouse."
ToolTipService.Placement="Mouse"/>
如果您需要显示任何FrameworkElements
(而不仅仅是文本),则可以这样设置工具提示:
<Button>
<ToolTipService.ToolTip>
<Border Background="Pink">
<StackPanel>
<Image .../>
<TextBlock .../>
</StackPanel>
</Border>
</ToolTipService.ToolTip>
</Button>
尝试这个
<Button Content="{Binding Path=Id}"
Command="{Binding DataContext.ShowPopupCommand,
RelativeSource={RelativeSource AncestorType=data:DataGrid}}"
ToolTip="{Binding SomeProperty}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.