AutomationProperties 類別

定義

提供取得或設定自動化屬性實例層級值的支援。 這些屬性值會設定為附加屬性, (通常是在 XAML) 中,並從控制項的 AutomationPeer補充或覆寫自動化屬性值。

public ref class AutomationProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AutomationProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class AutomationProperties
Public NotInheritable Class AutomationProperties
繼承
Object Platform::Object IInspectable AutomationProperties
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

提示

開啟 WinUI 3 資源庫應用程式,並查看下列協助工具原則:

WinUI 3 資源庫應用程式包含大部分 WinUI 3 控制項、特性和功能的互動式範例。 從Microsoft Store取得應用程式,或在GitHub上取得原始程式碼

備註

AutomationProperties 是數個 XAML 附加屬性的主機服務類別。 這些附加屬性的目的是要啟用設定各種每個實例值,這些值與 UI 元素如何回報給 Microsoft 消費者介面自動化協助工具架構相關。 在 UI 專案的類別設計尚未將其 Microsoft 消費者介面自動化整合或對等實作行為的一部分轉送其他 UI 相關屬性值,或轉送的值不是您想要向 Microsoft 消費者介面自動化回報的值時,這非常有用。

為了支援 XAML 處理器存取附加屬性,以及公開對等的 get 和 set 作業給程式碼,每個 XAML 附加屬性都有一對 GetSet 存取子方法,這也是 AutomationProperties 的成員。 例如,GetNameSetName方法支援,並提供對等的程式碼支援,以便將自動化Name值報告給 Microsoft 消費者介面自動化,而不是使用 Name 附加屬性在 XAML 中設定它。 或者,您可以使用相依性屬性系統來取得或設定附加屬性的值,這也會將基礎值報告給 Microsoft 消費者介面自動化。 呼叫 GetValueSetValue,傳遞要設定的相依性屬性識別碼引數,以及要取得或設定值的目標物件參考。

Name 屬性

在各種附加屬性中,可能是最重要的屬性是 Name。 這是因為當使用者在協助工具案例中與應用程式互動時,最常存取並回報的 Name 屬性。 Name可作為 UI 元素的人類可讀取識別碼。

各種 UI 元素都有對等轉送,可根據其他元素屬性提供預設 的 Name 值。 例如,Button類別的對等轉送會轉送Button內容的ToString評估,並使用此字串做為預設名稱。 若要覆寫該預設值,或為沒有 Microsoft 消費者介面自動化Name可用的任何 UI 元素案例提供Name值,請在 XAML 中設定該元素的Name附加屬性。 如需 Microsoft 消費者介面自動化名稱為何很重要的詳細資訊,請參閱基本協助工具資訊。 如需如何測試專案是否已經有對等提供 名稱 且很有用的詳細資訊,請參閱 輔助功能測試

基於當地語系化理由,您應該避免 XAML 中 Name 的硬式編碼字串值。 如果您在 元素上設定 x:Uid 指示詞 ,則可以使用 RESW 資源以屬性為目標,並提供不同的當地語系化值。 對於附加屬性,資源識別碼表單需要 XAML 表單中附加屬性的完整資格,包括其命名空間和 using: 前置詞。 例如,若要以具有x:Uid 指示詞值 「sendButton」 的資源AutomationProperties.Name 附加屬性值為目標,RESW 資源中的資料項目名稱值是sendButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name

如需每個附加屬性的詳細資訊,請參閱 附加屬性 的完整清單 (,請參閱每個屬性的識別碼 欄位) 。

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1511 10586 GetLandmarkType
1511 10586 GetLocalizedLandmarkType
1511 10586 SetLandmarkType
1511 10586 SetLocalizedLandmarkType
1607 14393 GetDescribedBy
1607 14393 GetFlowsFrom
1607 14393 GetFlowsTo
1607 14393 GetFullDescription
1607 14393 GetIsDataValidForForm
1607 14393 GetIsPeripheral
1607 14393 GetLocalizedControlType
1607 14393 SetFullDescription
1607 14393 SetIsDataValidForForm
1607 14393 SetIsPeripheral
1607 14393 SetLocalizedControlType
1703 15063 GetCulture
1703 15063 SetCulture
1803 17134 GetHeadingLevel
1803 17134 SetHeadingLevel
1809 17763 GetIsDialog
1809 17763 SetIsDialog

屬性

AcceleratorKeyProperty

識別 AutomationProperties.AcceleratorKey 附加屬性。

AccessibilityViewProperty

識別 AutomationProperties.AccessibilityView 附加屬性。

AccessKeyProperty

識別 AutomationProperties.AccessKey 附加屬性。

AnnotationsProperty

識別 AutomationProperties.Annotations 附加屬性。

AutomationControlTypeProperty

識別 AutomationProperties.AutomationControlType 附加屬性。

AutomationIdProperty

識別 AutomationProperties.AutomationId 附加屬性。

ControlledPeersProperty

識別 AutomationProperties.ControlledPeers 附加屬性。

CultureProperty

識別 AutomationProperties.Culture 附加屬性。

DescribedByProperty

識別 AutomationProperties.DescribedBy 附加屬性。

FlowsFromProperty

識別 FlowFrom 附加屬性。

FlowsToProperty

識別 FlowTo 附加屬性。

FullDescriptionProperty

識別 AutomationProperties.FullDescription XAML 附加屬性。

HeadingLevelProperty

識別 HeadingLevel XAML 附加屬性。

HelpTextProperty

識別 AutomationProperties.HelpText XAML 附加屬性。

IsDataValidForFormProperty

識別 AutomationProperties.IsDataValidForForm XAML 附加屬性。

IsDialogProperty

識別 AutomationProperties.IsDialog XAML 附加屬性。

IsPeripheralProperty

識別 AutomationProperties.IsPeripheral XAML 附加屬性。

IsRequiredForFormProperty

識別 AutomationProperties.IsRequiredForForm XAML 附加屬性。

ItemStatusProperty

識別 AutomationProperties.ItemStatus XAML 附加屬性。

ItemTypeProperty

識別 AutomationProperties.ItemType XAML 附加屬性。

LabeledByProperty

識別 AutomationProperties.LabeledBy XAML 附加屬性。

LandmarkTypeProperty

識別 AutomationProperties.LandmarkType XAML 附加屬性。

LevelProperty

識別 AutomationProperties.Level XAML 附加屬性。

LiveSettingProperty

識別 AutomationProperties.LiveSetting XAML 附加屬性。

LocalizedControlTypeProperty

識別 AutomationProperties.LocalizedControlType XAML 附加屬性,這是描述自動化專案所代表控制項類型的文字字串。

LocalizedLandmarkTypeProperty

識別 AutomationProperties.LocalizedLandmarkType XAML 附加屬性。

NameProperty

識別 AUTOMATIONPROPERTIES.NAME XAML 附加屬性。

PositionInSetProperty

識別 AutomationProperties.PositionInSet XAML 附加屬性。

SizeOfSetProperty

識別 AutomationProperties.SizeOfSet XAML 附加屬性。

附加屬性

AcceleratorKey

取得或設定字串,其中包含快速鍵 (也稱為自動化元素的快速鍵組合) 組合。

AccessibilityView

取得或設定專案的 Microsoft 消費者介面自動化樹狀檢視模式。

AccessKey

取得或設定字串,其中包含自動化專案的存取索引鍵字元。

Annotations

取得檔中的批註物件清單,例如批註、頁首、頁尾等等。

AutomationControlType

取得或設定 Microsoft 消費者介面自動化的控制項類型。

AutomationId

取得或設定可唯一識別專案給 Microsoft 消費者介面自動化的字串。

ControlledPeers

取得可由指定自動化專案操作的自動化專案集合。

Culture

取得或設定自動化元素的地區設定識別碼 (,例如,0x0409 「en-US」 或英文 (美國) ) 。

DescribedBy

取得專案陣列,提供自動化專案的詳細資訊。

FlowsFrom

取得自動化專案的陣列,這個陣列會建議目前自動化專案之前的讀取順序。

FlowsTo

取得自動化專案的陣列,這個陣列會建議目前自動化專案之後的讀取順序。

FullDescription

取得或設定當地語系化字串,其中包含專案的擴充描述文字。

HeadingLevel

取得或設定消費者介面自動化專案的標題層級。

HelpText

取得或設定與自動化專案相關聯的解說文字字串。

IsDataValidForForm

取得或設定值,這個值表示資料是否對表單有效。

IsDialog

取得或設定值,這個值表示自動化專案是否為對話方塊視窗。

IsPeripheral

取得或設定值,這個值表示自動化專案是否代表周邊 UI。

IsRequiredForForm

取得或設定值,這個值表示是否需要在表單上填寫專案。

ItemStatus

取得或設定專案中專案狀態的描述。

ItemType

取得或設定指定之項目型別的描述。

LabeledBy

取得或設定自動化專案,其中包含這個專案的文字標籤。

LandmarkType

取得或設定與專案相關聯的 地標類型識別碼

Level

取得或設定以 1 為基礎的整數,描述階層式或中斷階層式結構內元素的位置。

LiveSetting

取得或設定指定之專案的即時設定值,這個值是由代表即時區域的自動化專案所支援。

LocalizedControlType

取得或設定當地語系化的文字字串,描述自動化專案所代表的控制項類型。

LocalizedLandmarkType

取得或設定當地語系化的文字字串,描述自動化專案所代表的地標類型。

Name

取得或設定專案的消費者介面自動化名稱。

PositionInSet

取得或設定一個以 1 為基礎的整數,描述一組視為同層級之元素內的元素序數位置。

SizeOfSet

取得或設定一組視為同層級的專案中的專案數目。

方法

GetAcceleratorKey(DependencyObject)

取得指定DependencyObjectAutomationProperties.AcceleratorKey附加屬性的值。

GetAccessibilityView(DependencyObject)

取得指定DependencyObjectAutomationProperties.AccessibilityView附加屬性的值。

GetAccessKey(DependencyObject)

取得指定DependencyObjectAutomationProperties.AccessKey附加屬性的值。

GetAnnotations(DependencyObject)

取得指定DependencyObjectAutomationProperties.Annotations屬性值。

GetAutomationControlType(UIElement)

取得指定DependencyObjectAutomationProperties.AutomationControlType附加屬性的值。

GetAutomationId(DependencyObject)

取得指定DependencyObjectAutomationProperties.AutomationId附加屬性的值。

GetControlledPeers(DependencyObject)

靜態公用程式方法,可從目標擁有者擷取受控制的對等清單。

GetCulture(DependencyObject)

取得指定DependencyObject之 Culture XAML 附加屬性的值。

GetDescribedBy(DependencyObject)

取得專案集合,提供指定之自動化專案的詳細資訊。

GetFlowsFrom(DependencyObject)

取得自動化專案的清單,這個清單會建議指定之自動化專案之前的讀取順序。

GetFlowsTo(DependencyObject)

取得自動化專案的清單,這個清單會建議指定之自動化專案之後的讀取順序。

GetFullDescription(DependencyObject)

取得指定DependencyObjectAutomationProperties.FullDescription屬性值。

GetHeadingLevel(DependencyObject)

取得指定DependencyObjectAutomationProperties.HeadingLevel屬性值。

GetHelpText(DependencyObject)

取得指定DependencyObjectAutomationProperties.HelpText附加屬性的值。

GetIsDataValidForForm(DependencyObject)

取得指定DependencyObjectAutomationProperties.IsDataValidForForm屬性的值。

GetIsDialog(DependencyObject)

取得指定DependencyObjectAutomationProperties.IsDialog附加屬性的值。

GetIsPeripheral(DependencyObject)

取得布林值,指出指定的專案是否代表周邊 UI。

GetIsRequiredForForm(DependencyObject)

取得指定DependencyObjectAutomationProperties.IsRequiredForForm附加屬性的值。

GetItemStatus(DependencyObject)

取得指定DependencyObjectAutomationProperties.ItemStatus附加屬性的值。

GetItemType(DependencyObject)

取得指定DependencyObjectAutomationProperties.ItemType附加屬性的值。

GetLabeledBy(DependencyObject)

取得指定DependencyObjectAutomationProperties.LabeledBy附加屬性的值。

GetLandmarkType(DependencyObject)

取得指定 DependencyObject之地標類型附加屬性的值。

GetLevel(DependencyObject)

取得指定專案的 AutomationProperties.Level 屬性值。

GetLiveSetting(DependencyObject)

取得指定DependencyObjectAutomationProperties.LiveSetting附加屬性的值。

GetLocalizedControlType(DependencyObject)

取得當地語系化字串,指出指定之控制項的類型。

GetLocalizedLandmarkType(DependencyObject)

取得指定 DependencyObject之當地語系化地標類型附加屬性的值。

GetName(DependencyObject)

取得所指定DependencyObject之 AutomationProperties.Name附加屬性的值。

GetPositionInSet(DependencyObject)

取得指定DependencyObjectAutomationProperties.PositionInSet屬性值。

GetSizeOfSet(DependencyObject)

取得指定DependencyObjectAutomationProperties.SizeOfSet屬性值。

SetAcceleratorKey(DependencyObject, String)

設定指定DependencyObjectAutomationProperties.AcceleratorKey附加屬性的值。

SetAccessibilityView(DependencyObject, AccessibilityView)

設定指定DependencyObjectAutomationProperties.AccessibilityView附加屬性的值。

SetAccessKey(DependencyObject, String)

為指定的DependencyObject設定AutomationProperties.AccessKey附加屬性的值。

SetAutomationControlType(UIElement, AutomationControlType)

設定指定DependencyObjectAutomationProperties.AutomationControlType附加屬性的值。

SetAutomationId(DependencyObject, String)

設定指定DependencyObjectAutomationProperties.AutomationId附加屬性的值。

SetCulture(DependencyObject, Int32)

設定指定DependencyObject之 Culture附加屬性的值。

SetFullDescription(DependencyObject, String)

設定當地語系化字串,描述指定 DependencyObject的視覺外觀或內容。

SetHeadingLevel(DependencyObject, AutomationHeadingLevel)

為指定的DependencyObject設定AutomationProperties.HeadingLevel屬性的值。

SetHelpText(DependencyObject, String)

為指定的DependencyObject設定AutomationProperties.HelpText附加屬性的值。

SetIsDataValidForForm(DependencyObject, Boolean)

設定布林值,指出輸入或選取的值是否對與指定專案相關聯的表單規則有效。

SetIsDialog(DependencyObject, Boolean)

設定布林值,指出指定的專案是否應該識別為對話方塊視窗。

SetIsPeripheral(DependencyObject, Boolean)

設定布林值,指出指定的專案是否代表周邊 UI。

SetIsRequiredForForm(DependencyObject, Boolean)

設定指定DependencyObjectAutomationProperties.IsRequiredForForm附加屬性的值。

SetItemStatus(DependencyObject, String)

為指定的DependencyObject設定AutomationProperties.ItemStatus附加屬性的值。

SetItemType(DependencyObject, String)

設定指定DependencyObjectAutomationProperties.ItemType附加屬性的值。

SetLabeledBy(DependencyObject, UIElement)

設定指定DependencyObjectAutomationProperties.LabeledBy附加屬性的值。

SetLandmarkType(DependencyObject, AutomationLandmarkType)

設定指定 DependencyObject之地標類型附加屬性的值。

SetLevel(DependencyObject, Int32)

為指定的DependencyObject設定AutomationProperties.Level附加屬性的值。

SetLiveSetting(DependencyObject, AutomationLiveSetting)

為指定的DependencyObject設定AutomationProperties.LiveSetting附加屬性的值。

SetLocalizedControlType(DependencyObject, String)

設定當地語系化字串,指出指定控制項的類型。

SetLocalizedLandmarkType(DependencyObject, String)

設定指定 DependencyObject之當地語系化地標類型附加屬性的值。

SetName(DependencyObject, String)

設定所指定DependencyObjectAutomationProperties.Name附加屬性的值。

SetPositionInSet(DependencyObject, Int32)

設定指定DependencyObjectAutomationProperties.PositionInSet附加屬性的值。

SetSizeOfSet(DependencyObject, Int32)

設定指定DependencyObjectAutomationProperties.SizeOfSet附加屬性的值。

適用於

另請參閱