Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 6.08 KB

buttonbaseautomationpeer.md

File metadata and controls

51 lines (33 loc) · 6.08 KB
-api-id -api-type
T:Microsoft.UI.Xaml.Automation.Peers.ButtonBaseAutomationPeer
winrt class

Microsoft.UI.Xaml.Automation.Peers.ButtonBaseAutomationPeer

-description

Represents a base class for exposing classes derived from ButtonBase to Microsoft UI Automation.

-remarks

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.

Default peer implementation and overrides in ButtonBaseAutomationPeer

ButtonAutomationPeer has overrides of Core methods such that the associated AutomationPeer methods provide peer-specific information to a Microsoft UI Automation client.

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 derived classes

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:

-examples

-see-also

FrameworkElementAutomationPeer, ButtonAutomationPeer, Button, Custom automation peers