ContentElement.IsMouseOver 属性
定义
获取一个值,该值指示鼠标指针是否位于此元素(包括可视子元素或其控件组合)上。Gets a value that indicates whether the mouse pointer is located over this element (including visual child elements, or its control compositing).
public:
property bool IsMouseOver { bool get(); };
public bool IsMouseOver { get; }
member this.IsMouseOver : bool
Public ReadOnly Property IsMouseOver As Boolean
属性值
如果鼠标指针位于该元素或其子元素上方,则为 true
;否则为 false
。true
if mouse pointer is over the element or its child elements; otherwise, false
. 默认为 false
。The default is false
.
实现
示例
下面的示例创建一个样式,该样式包含在报表中提供替换可视行为的属性 Hyperlink setter IsMouseOver true
。The following example creates a style that includes a property setter that gives an alternate visual behavior when a Hyperlink reports IsMouseOver true
.
<Style.Triggers>
<Trigger Property="Hyperlink.IsEnabled" Value="false">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
<Trigger Property="Hyperlink.IsMouseOver" Value="true">
<Setter Property = "Foreground" Value="{StaticResource BlueGreenBrush}"/>
</Trigger>
</Style.Triggers>
注解
尽管不存在类似的 "IsMouseOverChanged" 事件,但有几个类似的事件。Although an analogous "IsMouseOverChanged" event does not exist, several similar events do. 例如,可以使用 MouseEnter 、 MouseMove 和 IsMouseDirectlyOverChanged 。For example, you can use MouseEnter, MouseMove, and IsMouseDirectlyOverChanged.
如果此元素捕获鼠标,则此属性将保留, true
直到鼠标捕获丢失,并且鼠标指针离开元素边界。If this element captures the mouse, this property remains true
until mouse capture is lost and the mouse pointer leaves the element bounds.
依赖项属性信息Dependency Property Information
标识符字段Identifier field | IsMouseOverProperty |
元数据属性设置为 true Metadata properties set to true |
无None |