开发者

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 th开发者_开发知识库e 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜