MultipleViewPattern.MultipleViewPatternInformation.CurrentView Свойство

Определение

Извлекает текущее представление для элемента управления.

public:
 property int CurrentView { int get(); };
public int CurrentView { get; }
member this.CurrentView : int
Public ReadOnly Property CurrentView As Integer

Значение свойства

Int32

Целочисленное значение для текущего представления объекта AutomationElement. Значение по умолчанию — 0.

Примеры

В следующем примере получается целочисленный идентификатор, представляющий текущее представление для элемента управления, поддерживающего MultipleViewPattern.

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

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

    return multipleViewPattern;
}
'/--------------------------------------------------------------------
'/ <summary>
'/ Obtains a MultipleViewPattern control pattern from an 
'/ automation element.
'/ </summary>
'/ <param name="targetControl">
'/ The automation element of interest.
'/ </param>
'/ <returns>
'/ A MultipleViewPattern object.
'/ </returns>
'/--------------------------------------------------------------------
Private Function GetMultipleViewPattern( _
ByVal targetControl As AutomationElement) As MultipleViewPattern
    Dim multipleViewPattern As MultipleViewPattern = Nothing

    Try
        multipleViewPattern = DirectCast( _
        targetControl.GetCurrentPattern(multipleViewPattern.Pattern), _
        MultipleViewPattern)
    Catch exc As InvalidOperationException
        'Object doesn't support the MultipleViewPattern control pattern
        Return Nothing
    End Try

    Return multipleViewPattern
End Function 'GetMultipleViewPattern
///--------------------------------------------------------------------
/// <summary>
/// Gets the current view identifier from a target.
/// </summary>
/// <param name="multipleViewPattern">
/// The control pattern of interest.
/// </param>
/// <returns>
/// The current view identifier.
/// </returns>
///--------------------------------------------------------------------
private int GetCurrentViewFromPattern(
    MultipleViewPattern multipleViewPattern)
{
    if (multipleViewPattern == null)
    {
        throw new ArgumentNullException(
            "MultipleViewPattern parameter must not be null.");
    }

    return multipleViewPattern.Current.CurrentView;
}
'/--------------------------------------------------------------------
'/ <summary>
'/ Gets the current view identifier from a target.
'/ </summary>
'/ <param name="multipleViewPattern">
'/ The control pattern of interest.
'/ </param>
'/ <returns>
'/ The current view identifier.
'/ </returns>
'/--------------------------------------------------------------------
Private Function GetCurrentViewFromPattern( _
ByVal multipleViewPattern As MultipleViewPattern) As Integer
    If multipleViewPattern Is Nothing Then
        Throw New ArgumentNullException( _
        "MultipleViewPattern parameter must not be null.")
    End If

    Return multipleViewPattern.Current.CurrentView

End Function 'GetCurrentViewFromPattern

Комментарии

Коллекция идентификаторов представлений идентична для экземпляров.

Применяется к