Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

FrameworkElementAutomationPeer.GetPattern Method

Silverlight

Returns an object that supports the requested pattern, based on the patterns supported by this FrameworkElementAutomationPeer.

Namespace:  System.Windows.Automation.Peers
Assembly:  System.Windows (in System.Windows.dll)
public override Object GetPattern(
	PatternInterface patternInterface
)

Parameters

patternInterface
Type: System.Windows.Automation.Peers.PatternInterface
One of the enumeration values.

Return Value

Type: System.Object
See Remarks.

The return value for this method in the FrameworkElementAutomationPeer implementation returns null in all cases. Override this method to report a specific pattern.

The following is a basic example implementation.

public override object GetPattern(PatternInterface patternInterface)
{
    if (patternInterface == PatternInterface.SelectionItem)
    {
        return this;
    }
    return null;
}

This example returns a result whenever the requester code has specified PatternInterface.SelectionItem as a requested pattern. Note the return of "this". The caller is then expected to cast "this" to the pattern interface that corresponds to the pattern they requested. In this case the calling code should cast the return value to ISelectionItemProvider, which then enables the calling code to invoke supported pattern members such as AddToSelection().

Note that many Silverlight peer implementations implement their supported pattern members through explicit interface implementations. This is one reason why callers should always cast the GetPattern return specifically to the interface of the desired pattern; the pattern members of a peer would otherwise not be accessible as direct members of the class.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.