I'm trying to implement a way to fetch all items from ListView with enabled virtualization for testing purposes. But apparently, despite the fact that Microsoft states that all controls since WPF 4 which supports virtualization have to have VirtualizedItemPattern implemented so a developer will be able to fetch all items from a container without implicit scrolling of the container.
My simple WPF application has ListView item inside Window element with added in the code-behind 100 elements. According to the MSDN, my expectation is that I'm able to get VirtualizedItemPattern from the ListView and call Realize() method to make the virtual item fully accessible as a UI Automation element. But the attempt to do it throws "Unsupported pattern" exception.
Well, the next my thought was like, maybe I made a mistake with choosing an item container and realized that none of those containers I tried is supporting this "feature".
And at this point, I completely stuck, since there is no documentation on this and no any examples. What happened with this feature? Has it been obsoleted? Any OS/some limitations (I tried on W7 and W10)?
Update: Ways I've tried to populate ListView:
var _list = Enumerable.Range(0, 100).Select(i => i.ToString());
foreach (var item in _list)
{
List.Items.Add(item);
}
then I had thought the problem might be in how I'm populating the control, so I decided to try ItemsSource
List.ItemsSource = _list;
In both cases, I got the same result - no way to get all items through UI automation framework.