How Can I get Cells (which is ControlType.Custom) inside a ListViewRow??

Feb 15, 2010 at 11:27 PM

Hi All,

I have a DataGrid, which contains three DataItem, each DataItem contains several Custom cells.

I start with

ListView listPriceCategoryGrid = GetControlByAutoIdAndText<ListView>(mainWin, "PriceCategoryGrid", "PriceCategoryGrid");

ListViewRows rows = listPriceCategoryGrid.Rows;
the rows has a Count = 3

ListViewRow rowNew = listPriceCategoryGrid.Rows[0];

This time I can fetch this rowNew, but the Cells count = 0

How can I get the cells inside this ListViewRow please?

Thanks a lot!


Feb 16, 2010 at 12:06 AM
Edited Feb 16, 2010 at 3:07 AM

According to this post:

my issue has been partly fixed.

Thanks, Throndorin!

If I have child node (say, a Text control) inside the Cell, how can i get it?




Feb 16, 2010 at 3:05 PM


Label label = cell.Get<Label>(SearchCriteria.ByControlType(ControlType.Text).AndByAutomationId("id"));

if there is no AutomationId

Label label = cell.Get<Label>(SearchCriteria.ByControlType(ControlType.Text));

label.Name => the text


if cell is a custom control you hat to add


using White.Core.UIItems.WPFUIItems;


in my example you have read is an operation on the customControl cell => GetText()

Feb 17, 2010 at 8:49 PM

Thanks Throndorin,

Actually If I want to get the lable inside the GridViewCell, i don't need to use your custom class to get the cells.

I can directly get the Lable from the GridViewRow, that's tricky....

Label label =row .Get<Label>(SearchCriteria.ByControlType(ControlType.Text).AndByAutomationId("id"));

Feb 18, 2010 at 6:56 AM



there is no trick but it might give you not the correct result :)


1.  Search on UIItem seems to be descendent search so all elements will be found not only direct children (AutomationElement.FindAll(TreeScope.Descendent, ....)  if you use UIAutomation without white.

2. But if there are several Label with the same id you will get only the first one.


Other way for WPF => IUIItem[] labels =row .GetMultiple(SearchCriteria.ByControlType(ControlType.Text).AndByAutomationId("id"));

works only on Standdard White Controls and only if using White.Core.UIItems.WPFUIItems; is used