IsKnownPartOf Method

Returns true if the child control is an integral part of the parent control, and should not be treated as a separate control.

Remarks

Implement this method in the custom server. It is called by UFT to determine if an element should be learned, or whether it is part of a higher-level control. If part of a higher-level control, the element is learned as part of that containing control.

A control can be composed of elements, but the properties and behaviors are associated with the control rather than the individual elements. For example, a calendar may contain buttons and listboxes, but the logical behaviors and properties belong to the calendar, not to the buttons and listboxes. For example, the "month" property is a property of the calendar control, not the contained month listbox.

If the control is to be learned as a single unit, the child elements are not learned. In this case, return true for the contained elements.

UFT may call this method for any control, not only on the control that this custom server supports. Therefore, in your implementation, use only the parameters passed to the method. Do not use the UtilityObject or any data members defined in the custom server.

Syntax

Visual Basic (Declaration) 
Overridable Function IsKnownPartOf( _
   ByVal Parent As Control, _
   ByVal Child As FrameworkElement _
) As Boolean
C# 
virtual bool IsKnownPartOf( 
   Control Parent,
   FrameworkElement Child
)

Parameters

Parent
A reference to a control supported by the custom  server. For example, a calendar control.
Child
A reference to a child control of the Parent element.

Return Value

Returns true to indicate to UFT that the child element is not to be learned.

Example

The following method, implemented in an accordion custom server, returns false if the specified child is contained in the expandable content part of an accordion item. In this case it might be a custom control embedded inside the accordion, and should not be treated as part of the accordion.
C#Copy Code
public bool IsKnownPartOf(Control Parent, FrameworkElement Child) 
{  
   // Check if the specified child is contained in the expandable content part of an accordion item. 
   bool isInContent = false;  
   DependencyObject ancestor = VisualTreeHelper.GetParent(Child);  
   while( (ancestor != null) && !(ancestor is MyToolkit.AccordionItem)  
              && !(ancestor is MyToolkit.Primitives.ExpandableContentControl))  
           ancestor = VisualTreeHelper.GetParent(ancestor); 
   if (ancestor is MyToolkit.Primitives.ExpandableContentControl))  
       // Custom element contained in expandable content part of an accordion item. Not an integral part of the accordion.  
       return false;   
   return true; 

See Also