語言

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

備註

此識別碼用於 使用者介面自動化 客戶端應用程式。 使用者介面自動化提供者應使用等效的識別碼為 AutomationElementIdentifiers。

此屬性也可從 Current 或 Cached 屬性中取得。

邊界矩形的類型 Rect為 。 回傳的矩形是在實體螢幕座標中。 預設值為 Empty。 Empty 若該項目目前未顯示使用者介面(UI),則會回傳。

回傳的矩形可能包含無法點擊的點。 這種情況可能發生的情況包括當 UI 項目形狀不規則或可點擊區域,或被其他 UI 元素遮擋時。

適用於

另請參閱