This is a migrated thread and some comments may be shown as answers.

Automating a Virtualized GridView Control

0 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tal
Top achievements
Rank 1
Tal asked on 11 Jun 2013, 01:05 PM
Hi,

I'm developing a library based on Microsoft's UI Automation Framework which allows creating automated tests involving the GridView control.

One of the main features of this library relating to this control is, of course, the ability to fetch all rows currently displayed in the grid. I do this by accessing the GridView's AutomationElement object in the UI tree, and then fetch all descendants that are of the GridViewRow class.

The problem is that the GridView in question is virtualized, hence the code described above only fetches a small part of the grid's content (the one that's currently visible).

Microsoft's suggestion of dealing with this problem is using the ItemContainer pattern, that exposes a method that allows to find all elements given a certain condition, regardless of whether or not they're virtualized, and then use the VirtualizedItem pattern's Realize() method in order to bring the item into view.

The problem I have with this is twofold: one, I couldn't find any AutomationElement that supports the ItemContainer pattern (not the GridView itself, and none of the custom elements under it). Two, even if I did, in order to construct a condition for the ItemContainer to work on, I need each row to have a unique identifier, and this is not the case. Even the RuntimeId property which is supposed to be unique gets recycled as you scroll down.

I can solve this problem by scrolling through the grid and fetching all unique elements, but clearly this is not the best solution, especially given the VirtualizedItem pattern intended exactly for this purpose.

I would love to hear the experts on this!

Tal

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Tal
Top achievements
Rank 1
Share this question
or