如何在鼠标悬停在按钮上时制作工具提示
本文关键字:工具提示 按钮 鼠标 悬停 | 更新日期: 2023-09-27 17:59:24
我是c#silverlight(5)初学者,对如何制作工具提示一无所知。事实上,我在工具箱里找不到任何工具提示的选项。
我要做的是当鼠标悬停在按钮上时显示工具提示。假设我有这样的按钮:
<Button Content="{Binding Path=Id}"
Command="{Binding DataContext.ShowPopupCommand,
RelativeSource={RelativeSource AncestorType=data:DataGrid}}"/>
现在如何在ViewModel.cs类中为此按钮创建工具提示?
有人能告诉我如何使用MVVM方法在c#silverlight应用程序中创建工具提示吗。我们非常感谢您提供的任何帮助代码。这将是一个很大的帮助。谢谢
<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}"/>