Export (0) Print
Expand All

TransformPattern.Move Method

Moves the control.

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

public void Move(
	double x,
	double y
)

Parameters

x
Type: System.Double

Absolute screen coordinates of the left side of the control.

y
Type: System.Double

Absolute screen coordinates of the top of the control.

ExceptionCondition
InvalidOperationException

The CanMove property is false.

An object cannot be moved, resized, or rotated such that its resulting screen location would be completely outside the coordinates of its container and inaccessible to keyboard or mouse. For example, when a top-level window is moved completely off-screen or a child object is moved outside the boundaries of the container's viewport. In these cases the object is placed as close to the requested screen coordinates as possible with the top or left coordinates overridden to be within the container boundaries.

In the following example, a TransformPattern control pattern is obtained from an AutomationElement and subsequently used to move the AutomationElement.

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

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

    return transformPattern;
}


...


///-------------------------------------------------------------------- 
/// <summary> 
/// Calls the TransformPattern.Move() method for an associated  
/// automation element. 
/// </summary> 
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from 
/// an automation element. 
/// </param> 
/// <param name="x">
/// The number of screen pixels to move the automation element  
/// horizontally. 
/// </param> 
/// <param name="y">
/// The number of screen pixels to move the automation element  
/// vertically. 
/// </param> 
///-------------------------------------------------------------------- 
private void MoveElement(
    TransformPattern transformPattern, double x, double y)
{
    try
    {
        if (transformPattern.Current.CanMove)
        {
            transformPattern.Move(x, y);
        }
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action 
        return;
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft