New to Telerik Test StudioStart a free 30-day trial

FrameworkElement Object

The FrameworkElement object is the base object that all visual elements and controls inherit from in the ArtOfTest.WebAii.Silverlight.UI namespace.

The FrameworkElement and all objects that inherit from it get the following infrastructure properties:

PropertyDescription
AbsoluteSiblingTagIndexGet the sibling tag index of this FrameworkElement.
AbsoluteTagIndexGet the absolute index of this XAML tag in the Visual Tree.
ActualHeightGets the rendered height of a FrameworkElement.
ActualWidthGets the rendered width of a FrameworkElement.
ApplicationGet the Application object that owns this element.
AutomationIdGets the AutomationId set on this element if any.
ChildrenGets the visual children of this element.
ClipGets or sets the Geometry used to define the outline of the contents of a UIElement.
DepthGet the depth of this element in the Visual Tree.
EnableValidateMouseLocationEnables or disables the validation of mouse click locations before performing mouse actions.
FindGet the Find object used to search the visual children of this element.
HeightGets or sets the suggested height of a FrameworkElement.
HorizontalAlignmentGets or sets the horizontal alignment characteristics applied to a FrameworkElement when it is composed within a layout parent, such as a panel or items control.
HostReturns the SilverlightApp object owning this FrameworkElement.
IsHitTestVisibleGets or sets whether the contained area of this UIElement can return true values for hit testing.
IsTestRegionReturns whether or not this FrameworkElement is contained inside a TestRegion (not supported in WebAii 2.0 Beta 2).
LanguageGets or sets localization/globalization language information that applies to a FrameworkElement.
MarginGets or sets the outer margin of a FrameworkElement.
MaxHeightGets or sets the maximum height constraint of a FrameworkElement.
MaxWidthGets or sets the maximum width constraint of a FrameworkElement.
MinHeightGets or sets the minimum height constraint of a FrameworkElement.
MinWidthGets or sets the minimum width constraint of a FrameworkElement.
NameGets (or sets, but see Remarks) the identifying name of the object. The name provides a reference that is initially markup-compiled. After a XAML processor creates the object tree from markup, run-time code can refer to a markup element by this name.
OpacityGets or sets the degree of the object's opacity.
OpacityMaskGets or sets the brush used to alter the opacity of regions of this object.
ProjectionGets or sets the perspective projection (3-D effect) to apply when rendering this UIElement.
RenderSizeGets the final render size of a UIElement.
RenderTransformGets or sets transform information that affects the rendering position of a UIElement.
RenderTransformOriginGets or sets the origin point of any possible render transform declared by RenderTransform, relative to the bounds of the UIElement.
ResourcesGets the locally defined resource dictionary. In XAML, you can establish resource items as child object elements of the <object.Resources> property element, through XAML implicit collection syntax.
StyleGets or sets an instance Style that is applied for this object during rendering.
TagNameIndexGets the tag name index of the xaml tag name in the visual tree.
TechnologyTypeGet the technology type of this element. Always returns TechnologyType.Silverlight for FrameworkElement objects.
TextContentGets the text content of this framework element if any.
UseLayoutRoundingGets or sets a value that determines whether rendering for the object and its subtree should use rounding behavior that aligns rendering to whole pixels.
UserGets the UI interaction object that allows you to interact with this framework element directly using real mouse and keyboard interactions.
VerticalAlignmentGets or sets the vertical alignment characteristics applied to a FrameworkElement when it is composed within a parent object such as a panel or items control.
VisibilityGets or sets the visibility of a UIElement. A UIElement that is not visible does not render and does not communicate its desired size to layout.
WaitGets a VisualWait object to be used on waiting for Visual elements in the VisualTree.
WidthGets or sets the width of a FrameworkElement.
XamlTagGet the XAML tag name of this FrameworkElement. This is used for hierarchy matching and traversal.

The FrameworkElement Methods

Before describing all of the methods of the FrameworkElement object I'd like to point out the following special features:

  1. VisualTree navigation: All FrameworkElements enable you to navigate the visual tree up or down. The object exposes methods and properties like Parent, Children, NextSibling, PreviousSibling, AnySibling<T>. The navigation also supports control sensitive navigation. For example, if you would like to find the parent 'Grid' that a certain text is contained in you do the following:

C#
WpfApplication app = Manager.ActiveApplication;
Assert.IsNotNull(app);

Grid containerGrid = app.Find.ByText("SomeText").Parent("Grid").As<Grid>();

OR

If you are working with a custom control that doesn't have a strongly-typed object under ArtOfTest.WebAii.Silverlight.UI, the navigation methods all offer a non-generic version that can be used to search for a certain type. For example, let's say you are trying to find the custom control "Bar" that contains some text, then you can do the following:

C#
WpfApplication app = Manager.ActiveApplication;
Assert.IsNotNull(app);

FrameworkElement barElement = app.Find.ByText("SomeText").Parent("Bar");

Parent, NextSibling, PreviousSibling & AnySibling all offer a non-generic versions in addition to the generic one.

  1. User Interaction object:

The FrameworkElement object exposes a user interaction object. The object is exposed as a property named 'User'. User then exposes all the real automation methods like moving the mouse to click an element, type a text, mouse enter, mouse leave…etc.

Note: One of the reasons why we moved these methods into their own object under 'User.xxx' is to help users differentiate between automation that is done by setting/getting properties vs. real automation that used the mouse or keyboard to invoke actions.

  1. Element coordinates:

All FrameworkElements offer the ability to get both the relative coordinates of the element within the Silverlight application and the actual coordinates in screen coordinates. The two methods are GetRectangle()and GetScreenRectangle().

Note: Given that WPF/Silverlight applications allow for rich transforms for visual elements (i.e. rotate, zoom….etc) and some elements like ellipses don't really conform to a rectangle per-say, our coordinate calculations will always return the largest rectangle that contains the actual element with its center right at the center of the element. For example, a GetRectangle on an ellipse will return this:

SL app

The highlighting above is using the FrameworkElement.Highlight() method.

  1. XML Representation:

Every FrameworkElement has a ToXml() method on it that returns the VisualTree of that element as an XML formatted string. This is very useful when trying to understand the visual tree at a certain state. [Hint: You can get the entire visual tree of an app by calling app.VisualTree.Root.ToXml()]

These are all of the FrameworkElement methods available for use by your automation code:

MethodDescription
AnySibling(T)Return any sibling of this control of type T. The framework first searches for a previous sibling having the specified type. If it finds one that sibling is returned. If it doesn't find one then it searches for the next sibling. If it find one that sibling is returned, otherwise null (Nothing in VB.NET) is returned.
As(T)Return this framework element as a strongly-typed control of type T.
CastAs(T)Returns this framework element as a strongly-typed control of type T without enforcing tag name to match the type it is being cast to. This functions gives you free casting abilities between types.
EqualsDetermines whether this FrameworkElement is equal to another, by comparing their AutomationReferences.
GetChildrenGet the children of this framework element.
GetNextSiblingGet the next sibling of this FrameworkElement.
GetParentGet the Parent of this element.
GetPrevSiblingGet the previous sibling.
GetRectangleGet the bounding rectangle of this FrameworkElement within the owning Silverlight application.
GetScreenRectangleReturn the actual coordinates of this element in absolute screen coordinates taking into account the location of the overall plug-in on the page.
HighlightHighlight this element in the Silverlight application.
NextSiblingGet the next sibling control of a specific type.
ParentGet the parent FrameworkElement of this element.
PreviousSiblingGet the previous sibling control of a specific type.
RefreshRefresh this FrameworkElement within the VisualTree.
ScrollToVisibleScrolls the web page so that this element is visible in the browser window.
ToXmlGets an XML formatted string that represents this element and all its children This XML represents the VisualTree.
In this article
The FrameworkElement Methods
Not finding the help you need?
Contact Support