WPF:ComboBoxItem 的 MouseOver 上的弹出窗口 [英] WPF: PopUp on MouseOver of a ComboBoxItem

查看:28
本文介绍了WPF:ComboBoxItem 的 MouseOver 上的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何在 ComboBoxItem 的 MouseOver 上显示 PopUp 的示例?TIA

Does anyone know of an example of how to display a PopUp on MouseOver of a ComboBoxItem? TIA

我知道如何创建、设置样式和定位 PopUp,但不知道如何显示它!我可能要退休了.

I know how to create, style and position the PopUp but not how to display it! I may be retired.

推荐答案

在我们开始之前,你能不能先使用一个工具提示?

Before we start, could you just use a tooltip?

否则,为 ComboBoxItem 的控件模板设置样式,将弹出窗口包含在您想要的样式中,但将 Isopen 属性设置为 false.

otherwise, style the ComboBoxItem's control telmplate, include your popup in the style positioned where you want but set the Isopen property to false.

在鼠标悬停时使用触发器将弹出窗口的 IsOpen 属性设置为 true.

Use a trigger on mouse over to set your popup's IsOpen property to true.

这里是一个例子使用触发器 OnMouseOver

here is an example of using a trigger OnMouseOver

你最终会得到一个像这样的触发器:-

you will end up with a trigger in your style like this :-

  <Style.Triggers>
    <Trigger Property="IsMouseOver" Value="True">
      <Setter TargetName="thePopupsName"
              Property="IsOpen"
              Value="True" />
    </Trigger>
  </Style.Triggers>

当 mouseOver 发生时弹出窗口将弹出,当它消失时弹出窗口将返回其默认值.

when the mouseOver occurs the popup will popup, when its gone the popup will return to its default value.

这篇关于WPF:ComboBoxItem 的 MouseOver 上的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆