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
public static final AutomationProperty SelectionProperty
public static final var SelectionProperty : AutomationProperty
Not applicable.

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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0