在WPF中,要在鼠标悬停时显示悬停信息气泡,可以使用ToolTip控件。以下是一个简单的示例:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Hover over me">
<Button.ToolTip>
<ToolTip Content="This is a tooltip!"/>
</Button.ToolTip>
</Button>
</Grid>
</Window>
Button button = new Button();
button.Content = "Hover over me";
ToolTip toolTip = new ToolTip();
toolTip.Content = "This is a tooltip!";
button.ToolTip = toolTip;
这样,当鼠标悬停在按钮上时,就会显示悬停信息气泡。
注意:本回答中不涉及云计算品牌商。
领取专属 10元无门槛券
手把手带您无忧上云