SelectionPattern.SelectionProperty Field
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Identifies the property that gets the selected items in a container.
public: static initonly System::Windows::Automation::AutomationProperty ^ SelectionProperty;
public static readonly System.Windows.Automation.AutomationProperty SelectionProperty;
staticval mutable SelectionProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly SelectionProperty As AutomationProperty
Field Value
Examples
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)
{
try
{
return selectionContainer.GetCurrentPropertyValue(
SelectionPattern.SelectionProperty) as AutomationElement[];
}
// Container is not enabled
catch (InvalidOperationException)
{
return null;
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Gets the currently selected SelectionItem objects from target.
''' </summary>
''' <param name="selectionContainer">
''' The current Selection container object.
''' </param>
'''--------------------------------------------------------------------
Private Function GetCurrentSelectionProperty( _
ByVal selectionContainer As AutomationElement) As AutomationElement()
Try
Return DirectCast(selectionContainer.GetCurrentPropertyValue( _
SelectionPattern.SelectionProperty), AutomationElement())
' Container is not enabled
Catch
Return Nothing
End Try
End Function 'GetCurrentSelectionProperty
Remarks
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.