SelectionPattern.SelectionPatternInformation.GetSelection Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recupera todos os itens selecionados no contentor de seleção.
public:
cli::array <System::Windows::Automation::AutomationElement ^> ^ GetSelection();
public System.Windows.Automation.AutomationElement[] GetSelection();
member this.GetSelection : unit -> System.Windows.Automation.AutomationElement[]
Public Function GetSelection () As AutomationElement()
Devoluções
A coleção de itens selecionados. O padrão é um array vazio.
Exemplos
No exemplo seguinte, obtém-se uma coleção de AutomationElements que representa os itens selecionados num contentor de seleção.
///--------------------------------------------------------------------
/// <summary>
/// Gets the currently selected SelectionItem objects from target.
/// </summary>
/// <param name="ae">The current Selection container object.</param>
///--------------------------------------------------------------------
private AutomationElement[] GetCurrentSelection(
AutomationElement selectionContainer)
{
try
{
SelectionPattern selectionPattern =
selectionContainer.GetCurrentPattern(
SelectionPattern.Pattern) as SelectionPattern;
return selectionPattern.Current.GetSelection();
}
// 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 GetCurrentSelection( _
ByVal selectionContainer As AutomationElement) As AutomationElement()
Try
Dim selectionPattern As SelectionPattern = _
selectionContainer.GetCurrentPattern(selectionPattern.Pattern)
Return selectionPattern.Current.GetSelection()
' Container is not enabled
Catch
Return Nothing
End Try
End Function 'GetCurrentSelection