다음을 통해 공유


DockPattern.SetDockPosition(DockPosition) 메서드

정의

도킹 컨테이너 내 요청된 DockPosition에서 AutomationElement를 도킹합니다.

public:
 void SetDockPosition(System::Windows::Automation::DockPosition dockPosition);
public void SetDockPosition (System.Windows.Automation.DockPosition dockPosition);
member this.SetDockPosition : System.Windows.Automation.DockPosition -> unit
Public Sub SetDockPosition (dockPosition As DockPosition)

매개 변수

dockPosition
DockPosition

도킹 컨테이너의 경계 및 컨테이너 내 다른 요소에 상대적인 도킹 위치입니다.

예외

컨트롤이 요청된 도킹 스타일을 실행할 수 없는 경우.

예제

다음 예제에서는 AutomationElement 가 DockPattern 컨트롤 패턴을 지 원하는 컨트롤을 나타내는 해당 dockPosition 수정 합니다.

///--------------------------------------------------------------------
/// <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>
/// Sets the dock position of a target.
/// </summary>
/// <param name="dockControl">
/// The automation element of interest.
/// </param>
/// <param name="dockPosition">
/// The requested DockPosition.
/// </param>
///--------------------------------------------------------------------
private void SetDockPositionOfControl(
    AutomationElement dockControl, DockPosition dockPosition)
{
    if (dockControl == null)
    {
        throw new ArgumentNullException(
            "AutomationElement parameter must not be null.");
    }

    try
    {
        DockPattern dockPattern = GetDockPattern(dockControl);
        if (dockPattern == null)
        {
            return;
        }
        dockPattern.SetDockPosition(dockPosition);
    }
    catch (InvalidOperationException)
    {
        // When a control is not able to dock.
        // TO DO: error handling
    }
}
'''--------------------------------------------------------------------
''' <summary>
''' Sets the dock position of a target.
''' </summary>
''' <param name="dockControl">
''' The automation element of interest.
''' </param>
''' <param name="dockPosition">
''' The requested DockPosition.
''' </param>
'''--------------------------------------------------------------------
Private Sub SetDockPositionOfControl( _
ByVal dockControl As AutomationElement, _
ByVal dockPosition As DockPosition)
    If dockControl Is Nothing Then
        Throw New ArgumentNullException( _
        "AutomationElement parameter must not be null.")
    End If

    Try
        Dim dockPattern As DockPattern = GetDockPattern(dockControl)
        If dockPattern Is Nothing Then
            Return
        End If
        dockPattern.SetDockPosition(dockPosition)
    Catch exc As InvalidOperationException
        ' When a control is not able to dock.
        ' TO DO: error handling
    End Try

End Sub

설명

도킹 컨테이너는 허용 하는 컨트롤 자식 요소를 가로 또는 세로로 도킹 컨테이너 및 컨테이너 내에서 다른 요소의 경계를 기준으로 합니다.

적용 대상