UIElement.IsMouseDirectlyOver Property


获取一个值,该值指示在考虑元素组合的情况下,鼠标指针的位置是否与命中测试结果相对应。Gets a value that indicates whether the position of the mouse pointer corresponds to hit test results, which take element compositing into account. 这是依赖项属性。This is a dependency property.

 property bool IsMouseDirectlyOver { bool get(); };
public bool IsMouseDirectlyOver { get; }
member this.IsMouseDirectlyOver : bool
Public ReadOnly Property IsMouseDirectlyOver As Boolean

Property Value


如果鼠标指针位于与命中测试相同的元素结果上,则为true ;否则为 falsetrue if the mouse pointer is over the same element result as a hit test; otherwise, false. 默认值为 falseThe default is false.



IsMouseOver不同,仅当鼠标指针位于文本元素上时才 true 此属性,因为它适用于命中测试。Unlike IsMouseOver, this property is only true if the mouse pointer is over the literal element - as it is for a hit test. 如果鼠标指针在子元素上,而不是作为元素的更深层模板和组合的一部分的元素,则此属性将 falseIf the mouse pointer is instead over a child element, in particular over elements that are part of an element's deeper template and compositing, this property will be false. 除非您知道控件的组合方式(例如,在自定义控件模板中对您定义的控件使用此属性),否则此属性可能会返回意外的结果。Unless you know how a control is composited (for example, you use this property in a custom control template for a control that you define), this property might return unexpected results. 对于不是创作控件的大多数情况,请改用 IsMouseOverFor most scenarios where you are not authoring controls, use IsMouseOver instead.

如果此元素捕获鼠标并且此属性在捕获时 true,则此属性将继续返回 true,直至鼠标捕获丢失并且指针不在其边界上。If the mouse is captured by this element, and this property is true at time of capture, this property will continue to return true until mouse capture is lost and the pointer is not over its bounds.

依赖项属性信息Dependency Property Information

标识符字段Identifier field IsMouseDirectlyOverProperty
元数据属性设置为 trueMetadata properties set to true NoneNone

Applies to

See also