语言

AutomationElement.BoundingRectangleProperty 字段

定义

标识 BoundingRectangle 属性。

public: static initonly System::Windows::Automation::AutomationProperty ^ BoundingRectangleProperty;
public static readonly System.Windows.Automation.AutomationProperty BoundingRectangleProperty;
 staticval mutable BoundingRectangleProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly BoundingRectangleProperty As AutomationProperty 

字段值

示例

以下示例检索属性的当前值。 如果元素不提供默认值,则返回默认值。

System.Windows.Rect boundingRect = (System.Windows.Rect)
    autoElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty);
Dim boundingRect As System.Windows.Rect = CType(autoElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty), System.Windows.Rect)

下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则返回而不是默认值。

System.Windows.Rect boundingRect1;
object boundingRectNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty, true);
if (boundingRectNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
    boundingRect1 = (System.Windows.Rect)boundingRectNoDefault;
}
Dim boundingRect1 As System.Windows.Rect
Dim boundingRectNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty, True)
If boundingRectNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    boundingRect1 = DirectCast(boundingRectNoDefault, System.Windows.Rect)
End If

注解

此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 AutomationElementIdentifiers 中的等效标识符。

也可以从 Current 或 Cached 属性中检索此属性。

边界矩形的类型 Rect。 返回的矩形位于物理屏幕坐标中。 默认值为 Empty。 Empty 如果项当前未显示用户界面(UI),则返回 。

返回的矩形可以包含不可单击的点。 如果 UI 项具有不规则的形状或可单击区域,或者它被其他 UI 元素遮盖,则可能会出现这种情况的实例。

适用于

另请参阅