Stephan
Stephan

Reputation: 5488

Silverlight UI Automation of a TextBlock

I'm trying to set up UI automation for Silverlight 3. I have a little test project that has 2 elements, a Button and a TextBlock. When you click the button the text is supposed to change.

I have been able to simulate a button click and the text does correctly change on the UI. However I am having problems retrieving the text from the TextBlock. UISpy shows that it is of type "text" but it also shows that it implements no control patterns. If I use a TextBox I can get the text correctly using a ValuePattern, but I would prefer to use TextBlock.

Does anyone know how to get the current text of a TextBlock from it's AutomationElement object?

Upvotes: 1

Views: 1288

Answers (1)

GraemeF
GraemeF

Reputation: 11457

TextBlock exposes its text as the Name property of the automation element, so you can read the text from myTextBlockAutomationElement.Current.Name.

Upvotes: 2

Related Questions