DockPattern.DockPatternInformation.DockPosition 属性

定义

检索停靠容器内的一个 DockPositionAutomationElement

public:
 property System::Windows::Automation::DockPosition DockPosition { System::Windows::Automation::DockPosition get(); };
public System.Windows.Automation.DockPosition DockPosition { get; }
member this.DockPosition : System.Windows.Automation.DockPosition
Public ReadOnly Property DockPosition As DockPosition

属性值

DockPosition

元素相对于停靠容器和容器内其他元素的边界的 DockPosition

示例

在以下示例中,获取一个 DockPosition 值,表示支持的 DockPattern控件的当前停靠位置。

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

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

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

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

    Return dockPattern

End Function 'GetDockPattern
///--------------------------------------------------------------------
/// <summary>
/// Gets the current view identifier from a target.
/// </summary>
/// <param name="dockPattern">
/// The control pattern of interest.
/// </param>
/// <returns>
/// The current dock position.
/// </returns>
///--------------------------------------------------------------------
private DockPosition GetCurrentDockPosition(
    DockPattern dockPattern)
{
    if (dockPattern == null)
    {
        throw new ArgumentNullException(
            "DockPattern parameter must not be null.");
    }

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

    Return dockPattern.Current.DockPosition

End Function 'GetCurrentDockPosition

注解

停靠容器是一个控件,它允许相对于停靠容器边界和容器内其他元素的水平和垂直方式排列子元素。

默认值是 None

适用于