This documentation is archived and is not being maintained.

SelectionPattern.SelectionPatternInformation.CanSelectMultiple Property

Gets a value that specifies whether the container allows more than one child element to be selected concurrently.

Namespace: System.Windows.Automation
Assembly: UIAutomationClient (in uiautomationclient.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool CanSelectMultiple { get; }
/** @property */
public boolean get_CanSelectMultiple ()

public function get CanSelectMultiple () : boolean

Not applicable.

Property Value

true if the control supports multiple selection; otherwise false.

This property can be dynamic For example, in rare cases, a control might allow multiple items to be selected on initialization, but subsequently allow only single selections to be made.

In the following example, a SelectionPatterncontrol pattern is obtained from an AutomationElement and subsequently used to retrieve property values.

    ///--------------------------------------------------------------------
    /// <summary>
    /// Obtains a SelectionPattern control pattern from an 
    /// automation element.
    /// </summary>
    /// <param name="targetControl">
    /// The automation element of interest.
    /// </param>
    /// <returns>
    /// A SelectionPattern object.
    /// </returns>
    ///--------------------------------------------------------------------
    private SelectionPattern GetSelectionPattern(
        AutomationElement targetControl)
    {
        SelectionPattern selectionPattern = null;

        try
        {
            selectionPattern =
                targetControl.GetCurrentPattern(SelectionPattern.Pattern)
                as SelectionPattern;
        }
        // Object doesn't support the SelectionPattern control pattern
        catch (InvalidOperationException)
        {
            return null;
        }

        return selectionPattern;
    }

...

    ///--------------------------------------------------------------------
    /// <summary>
    /// Gets the current property values from target.
    /// </summary>
    /// <param name="selectionPattern">
    /// A SelectionPattern control pattern obtained from 
    /// an automation element representing the selection control.
    /// </param>
    /// <param name="automationProperty">
    /// The automation property of interest.
    /// </param>
    ///--------------------------------------------------------------------
    private bool GetSelectionObjectProperty(
        SelectionPattern selectionPattern,
        AutomationProperty automationProperty)
    {
        if (automationProperty.Id == 
            SelectionPattern.CanSelectMultipleProperty.Id)
        {
            return selectionPattern.Current.CanSelectMultiple;
        }
        if (automationProperty.Id == 
            SelectionPattern.IsSelectionRequiredProperty.Id)
        {
            return selectionPattern.Current.IsSelectionRequired;
        }
        return false;
    }

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
Show: