-api-id | -api-type |
---|---|
T:Microsoft.UI.Xaml.Automation.Peers.ButtonBaseAutomationPeer |
winrt class |
Represents a base class for exposing classes derived from ButtonBase to Microsoft UI Automation.
ButtonBaseAutomationPeer has a protected constructor, so you won't be able to use it directly for an OnCreateAutomationPeer definition. Derive your automation peer from ButtonBaseAutomationPeer if you are deriving a custom class from ButtonBase and want to add automation support for additional features that you enabled in your custom class. Then override OnCreateAutomationPeer so that it returns your custom peer. Note that ButtonBase already has derived classes, each of which also has a derived peer, so make sure that you really want to derive from this base class rather than use one of the existing XAML-enabled derived button classes.
ButtonAutomationPeer has overrides of Core methods such that the associated AutomationPeer methods provide peer-specific information to a Microsoft UI Automation client.
- GetName returns a string value based on examining the current Content. This is implemented so that consumers of the control don't always need to provide an AutomationProperties.Name value in app code, and can use a generated-from-content value for the automation Name directly from the UI definition. For more info on how this works, see Basic accessibility information.
- Other normally required values such as GetClassName and GetAutomationControlType should be implemented on the derived peer classes. The peer also has other behaviors that are provided by the base FrameworkElementAutomationPeer class. For more info, see "Base implementation in FrameworkElementAutomationPeer" section of Custom automation peers.
There is no "ControlAutomationPeer" class. FrameworkElementAutomationPeer serves as implementation for all basic Control class scenarios that involve Microsoft UI Automation. This includes behavior that does not necessarily appear as a public API exposure, such as the practical implementations of many of the Core methods from AutomationPeer.
FrameworkElementAutomationPeer includes extensive base implementation of peer behavior that other peers can use to report information that comes from owner classes at the UIElement and FrameworkElement level. For more info, see "Base implementation in FrameworkElementAutomationPeer" section of Custom automation peers.
In addition to the Core overrides, FrameworkElementAutomationPeer has two static utility methods that are useful for getting a peer handle from within control code, or for generating items peers from an item container peer for Microsoft UI Automation support. These are:
If you have a need to define a custom automation peer and can't identify a more derived peer class that pairs up with the control or base class you are deriving the owner class from, you should base your peer on FrameworkElementAutomationPeer. Even if the owner class isn't necessarily a FrameworkElement, you can't practically derive peers from AutomationPeer directly because FrameworkElementAutomationPeer has many overrides that provide the expected behavior for layout, automation and UI interactions. You do need to derive your owner class from UIElement at least, otherwise there is no way to create the peer on automation tree load with OnCreateAutomationPeer.
ButtonBaseAutomationPeer is the parent class for several immediately derived classes that implement peer support for Windows Runtime controls. Here is the list of classes that directly derive from ButtonBaseAutomationPeer:
- ButtonAutomationPeer
- HyperlinkButtonAutomationPeer
- RepeatButtonAutomationPeer
- ToggleButtonAutomationPeer
FrameworkElementAutomationPeer, ButtonAutomationPeer, Button, Custom automation peers