This project is read-only.

Cannot find items under Templated DataGridCell

Nov 11, 2011 at 12:08 PM
Edited Nov 11, 2011 at 12:14 PM


I'm accessing WPF DataGrid's cells using MyListViewCell class and its GetTest() method. The class was shown here: It works fine for "DataGridTextColumn"s. However, if I use DataGridTemplateColumn, MyListViewCell.GetText() does not find any controls under the associated AutomationElement.

My Custom-templated Cell's UI-tree looks like this in Snoop: DataGridCell --> Border --> ContentPresenter --> ConentPresenter --> ContentPresenter --> TextBlock.

The presenters' content is selected based on DataTemplate triggers. But eventually, the value is just in a plain TextBlock. If i add follwing code "this.GetMultiple(SearchCriteria.All);" in MyListViewCell.GetText(), it returns 0 UIItems.

Any ideas how I could access the templated text block in the DataGridCell?



Nov 11, 2011 at 12:24 PM


does UIAVerify see the element?


if not you need access to the developer he should read this:



Nov 11, 2011 at 1:07 PM
Hi Throndorin,
UiAVerify does not see the TextBlock and LogStructure does not show it either. Only Snoop finds the TextBlock. I tried with the UiAutomationTextBlock solution mentioned in the above link, but without any results. I also changed the TextBlock to TextBox without results.
Seems really strange...
Nov 11, 2011 at 2:11 PM
Edited Nov 11, 2011 at 2:15 PM

Whoops,  I modified wrong template first. The link above really did solve the problem! Thank you so much Throndorin. Saved my day!

Best Regards,