This documentation is archived and is not being maintained.

SelectionPattern.SelectionProperty Field

Identifies the property that gets the selected items in a container.

Namespace:  System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

public static readonly AutomationProperty SelectionProperty

This identifier is used by UI Automation client applications. UI Automation providers should use the equivalent field in SelectionPatternIdentifiers.

This property is not present in SelectionPattern.SelectionPatternInformation and must be retrieved by using GetCurrentPropertyValue or GetCachedPropertyValue.

In the following example, a collection of AutomationElements representing the selected items in a selection container is obtained.

/// <summary> 
/// Gets the currently selected SelectionItem objects from target. 
/// </summary> 
/// <param name="selectionContainer">
/// The current Selection container object. 
/// </param> 
private AutomationElement[] GetCurrentSelectionProperty(
    AutomationElement selectionContainer)
        return selectionContainer.GetCurrentPropertyValue(
            SelectionPattern.SelectionProperty) as AutomationElement[];
    // Container is not enabled 
    catch (InvalidOperationException)
        return null;

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0