SelectionPattern.SelectionPatternInformation.CanSelectMultiple Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che specifica se il contenitore consente la selezione simultanea di più di un elemento figlio.
public:
property bool CanSelectMultiple { bool get(); };
public bool CanSelectMultiple { get; }
member this.CanSelectMultiple : bool
Public ReadOnly Property CanSelectMultiple As Boolean
Valore della proprietà
true
se il controllo supporta selezioni multiple. In caso contrario, false
.
Esempio
Nell'esempio seguente viene ottenuto un SelectionPattern modello di controllo da un oggetto AutomationElement e successivamente usato per recuperare i valori delle proprietà.
///--------------------------------------------------------------------
/// <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>
''' 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 Function GetSelectionPattern( _
ByVal targetControl As AutomationElement) As SelectionPattern
Dim selectionPattern As SelectionPattern = Nothing
Try
selectionPattern = DirectCast( _
targetControl.GetCurrentPattern(selectionPattern.Pattern), _
SelectionPattern)
' Object doesn't support the SelectionPattern control pattern
Catch
Return Nothing
End Try
Return selectionPattern
End Function 'GetSelectionPattern
///--------------------------------------------------------------------
/// <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;
}
'''--------------------------------------------------------------------
''' <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 Function GetSelectionObjectProperty( _
ByVal selectionPattern As SelectionPattern, _
ByVal automationProperty As AutomationProperty) As Boolean
If automationProperty.Id = _
selectionPattern.CanSelectMultipleProperty.Id Then
Return selectionPattern.Current.CanSelectMultiple
End If
If automationProperty.Id = _
selectionPattern.IsSelectionRequiredProperty.Id Then
Return selectionPattern.Current.IsSelectionRequired
End If
Return False
End Function 'GetSelectionObjectProperty
Commenti
Questa proprietà può essere dinamica, ad esempio, in rari casi, un controllo potrebbe consentire l'selezione di più elementi per l'inizializzazione, ma in seguito consente di effettuare solo singole selezioni.