FrameworkElementAutomationPeer class
TOC
Collapse the table of content
Expand the table of content

FrameworkElementAutomationPeer class

Exposes FrameworkElement derived types (including all controls) to Microsoft UI Automation.

Inheritance

Object
  DependencyObject
    AutomationPeer
      FrameworkElementAutomationPeer

Syntax


public class FrameworkElementAutomationPeer : AutomationPeer

Members

The FrameworkElementAutomationPeer class has these types of members:

Constructors

The FrameworkElementAutomationPeer class has these constructors.

ConstructorDescription
FrameworkElementAutomationPeer Initializes a new instance of the FrameworkElementAutomationPeer class.

 

Methods

The FrameworkElementAutomationPeer class has these methods. It also inherits methods from the Object class.

MethodDescription
CreatePeerForElement Creates a FrameworkElementAutomationPeer for the specified UIElement.
FromElement Returns the FrameworkElementAutomationPeer for the specified UIElement.

 

Properties

The FrameworkElementAutomationPeer class has these properties.

PropertyAccess typeDescription

Owner

Read-only

Gets the UIElement owner that is associated with this FrameworkElementAutomationPeer.

 

Remarks

There is no "ControlAutomationPeer" class. FrameworkElementAutomationPeer serves as implementation for all basic Control class scenarios that involve 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 the "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 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.

FrameworkElementAutomationPeer derived classes

FrameworkElementAutomationPeer is the parent class for several immediately derived classes that implement peer support for Windows Runtime controls and elements. Some of these peer classes are peers that match control base classes rather than practical controls. For example ButtonBaseAutomationPeer exists so that it can define shared peer behavior for several classes that support the practical Button classes that derive from ButtonBase. Here is the list of classes that directly derive from FrameworkElementAutomationPeer:

Examples

This example shows the basic subclass requirements for deriving a peer from FrameworkElementAutomationPeer and supporting at least one control pattern. This code is an excerpt from the XAML accessibility sample.


        public class MediaContainerAP : FrameworkElementAutomationPeer, IRangeValueProvider, IToggleProvider
        {
            MediaElement _mediaElement;
            FrameworkElement _labeledBy;
// nondefault ctors omitted
            protected override object GetPatternCore(PatternInterface patternInterface)
            {
                if (patternInterface == PatternInterface.RangeValue)
                {
                    return this;
                }
                else if (patternInterface == PatternInterface.Toggle)
                {
                    return this;
                }
                return null;
            }


            protected override AutomationControlType GetAutomationControlTypeCore()
            {
                return AutomationControlType.Group;
            }

            protected override string GetLocalizedControlTypeCore()
            {
                return "Video";
            }

            protected override string GetClassNameCore()
            {
                return "MediaElementContainer";
            }
// pattern implementation omitted ...
        }


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Automation.Peers
Windows::UI::Xaml::Automation::Peers [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Automation.Peers
Windows::UI::Xaml::Automation::Peers [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

See also

Object
FrameworkElement
Custom automation peers
AutomationPeer
XAML accessibility sample

 

 

Show:
© 2016 Microsoft