Forum Discussion

Kazuya's avatar
14 years ago

Silverlight controls - few proprties ?

Greetings,



the only property i can rely on while accessing a silverlight control is the 'SlObjectName' property, however sometimes when my controls are generated during the run time it'll be empty, and I can't really rely on the class or type; because there might be similar controls in the same User Control or the xaml file.



So, I was hoping if you guys could help me out in this, which is "How to uniquely access dynamically generated or added controls?"



Thanks.
  • Hi Kazuya,



    If you want to address Silverlight objects by their names (the value of the SlObjectName object property in TestComplete), try to specify unique names for the controls when they are dynamically generated in your application's code (that is, set the Name property for the controls). Otherwise, if you do not specify names for dynamic objects before adding them to the application's layout, TestComplete will be able to address them only by the class name, caption and index passed to the SlObject method (see the "Addressing the Application’s Controls and Objects" section in the Addressing Objects of Silverlight Applications help topic).



    Furthermore, you can use the Name Mapping feature to address objects of your application in tests. In this case, you can map a dynamically created control and use some of its unique properties (if any) as name mapping criteria to identify the object. Please see help topics from the Mapping Application Objects and Modifying Mapping Criteria sections for more information about this.