WPF: PopUp on MouseOver of a ComboBoxItem

ぃ、小莉子 提交于 2020-01-11 08:04:04

问题


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

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


回答1:


Before we start, could you just use a tooltip?

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

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

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>

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



来源:https://stackoverflow.com/questions/1869497/wpf-popup-on-mouseover-of-a-comboboxitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!