![](/img/trans.png)
[英]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.