编辑:根据您的意见,您可以处理的提示打开/在你MouseEnter
和MouseExit
事件处理程序关闭。
您可以使用工具提示和任何你喜欢的方式。这会给你适当的“弹出”行为。工具提示本身的行为可以使用附加属性ToolTipService
定义。这应该让你开始。
<Ellipse x:Name="_ellipse" Width="100" Height="100" Fill="Purple">
<Ellipse.Resources>
<Style TargetType="{x:Type ToolTip}">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="Gray"/>
</Style>
<Style TargetType="{x:Type Ellipse}">
<Setter Property="ToolTip" Value="Your tooltip text."/>
<Setter Property="ToolTipService.InitialShowDelay" Value="0"/>
<Setter Property="ToolTipService.Placement" Value="Right,Absolute"/>
<Setter Property="ToolTipService.VerticalOffset" Value="40"/>
</Style>
</Ellipse.Resources>
</Ellipse>
然后,在你的代码隐藏MouseEnter
处理
private void _txt_MouseEnter(object sender, MouseEventArgs e)
{
Ellipse thisSender = (Ellipse)sender;
Tooltip tooltip = (ToolTip)thisSender.ToolTip;
tooltip.IsOpen = true;
}
我不能使用工具提示的应用程序将在触摸屏系统上运行,因此用户不能做鼠标移到看到提示。如果用户触摸紫色问号图标,它总是会发出点击事件。 –
@RobinPurbia,按照你的问题,你怎么期望'MouseEnter'事件触发? –
MouseEnter和MouseLeave事件正在工作,我试过了。我只是想帮助制作这样的Popup。感谢您的及时回应。 –