SelectionPattern.SelectionPatternInformation.IsSelectionRequired 속성

정의

컨테이너 하나 이상의 자식 항목을 선택해야 하는지 여부를 지정하는 값을 가져옵니다.Gets a value that specifies whether the container requires at least one child item to be selected.

public:
 property bool IsSelectionRequired { bool get(); };
public bool IsSelectionRequired { get; }
member this.IsSelectionRequired : bool
Public ReadOnly Property IsSelectionRequired As Boolean

속성 값

Boolean

컨트롤에서 하나 이상의 항목을 선택해야 하면 true이고, 그렇지 않으면 false입니다.true if the control requires at least one item to be selected; otherwise false.

예제

다음 예제에서는 SelectionPattern 컨트롤 패턴에서 가져온는 AutomationElement 을 사용 하 여 속성 값을 검색 합니다.In the following example, a SelectionPattern control 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>
''' 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

설명

이 속성은 동적일 수 있습니다.This property can be dynamic. 예를 들어, 컨트롤의 초기 상태에서 기본적으로 항목이 선택되지 않을 수 있으며 이는 IsSelectionRequiredfalse임을 나타냅니다.For example, the initial state of a control might not have any items selected by default, indicating that IsSelectionRequired is false. 그러나 항목이 선택된 후에는 컨트롤에 하나 이상의 항목이 항상 선택되어 있어야 합니다.However, after an item is selected, the control must always have at least one item selected.

적용 대상