Forum Discussion

bjohnson_1's avatar
bjohnson_1
Occasional Contributor
14 years ago

WPF Template Triggers

I am testing an application built in C#. As part of the application they developed field level error messages. It appreas that message are rendered via templates which are called by various triggers. Example a required field which loses focus with no data entered calls a trigger to display a message denoting to enter data.



I have been able to find the individual trigger definitions which populate the data I want to verify. However I have not found the property which tells me that trigger has been called/activated.



Since test complete cannot see the field level message rendered on the screen, I need to find some property which will allow me to validate the error was displayed.



Any ideas?



Thanks

1 Reply

  • Brent,


    I'm not a WPF guru, but will try to help.

    I investigated the situation on the Binding Validation sample application included in MSDN.

    When you enter an invalid value in the edit box in this application, it displays the exclamation mark next to this edit box (see img1 attached). Is it the field level error that you are talking about?


    I explored the application with the Object Spy and the Object Browser. I noticed that when an error of this kind occurs, the object tree in the Object Browser panel contains specific objects (see img2). These objects aren't present if the error does not occur. So, you can check whether these objects are present to verify whether an error occurred. (You can use code like ...WPFObject("AdornerPlayer", "", 1).WPFObject("TemplatedAdorner", "", 1).Exist). 


    The control displaying the error symbol is a composite control. To get the error text, you need to modify project properties so that TestComplete recognizes that control as a composite WPF component:


    *  Right-click the project node in Project Explorer and select Edit | Properties from the context menu. This will invoke the  project properties editor.

    *  In the editor, select the Open Applications | WPF category on the left.

    *  Click Add to append a new entry to the Composite controls list.

    *  Enter Control into the Class name cell and select the Active check box.

    *  Save the changes.


    Now, in the Object Browser, you will see child controls and the one that provides access to the error text (see img3, pay attention to the object with "!" in the caption).


    I hope this helps.