DockPattern.DockPatternInformation.DockPosition Property

 

Retrieves the DockPosition of an AutomationElement within a docking container.

Namespace:   System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

public DockPosition DockPosition { get; }

Property Value

Type: System.Windows.Automation.DockPosition

The DockPosition of the element, relative to the boundaries of the docking container and other elements within the container.

A docking container is a control that allows the arrangement of child elements, both horizontally and vertically, relative to the boundaries of the docking container and other elements within the container.

The default value is None.

In the following example, a DockPosition value is obtained representing the current dock position for a control that supports 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>
/// 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;
}

.NET Framework
Available since 3.0
Return to top
Show: