WPF ListView control that using VirtualMode

Class library usage, coding and language questions.
domperez
Posts: 6
Joined: Tue Oct 30, 2007 4:23 pm

WPF ListView control that using VirtualMode

Post by domperez » Fri Sep 11, 2009 4:16 pm

I'm having a bit of trouble with a WPF ListView control that uses VirtualMode. I am able to get the row count but I'm unable to access the contents of rows that are off screen. I can select every row before I read it but this is painfully slow (30minutes for 1000 rows).

It seems like Ranorex Spy has a similar problem, if I try to inspect one of these controls with more than a handfull of rows it "locks up".

I there a better way to handle this?

Does Ranorex provide access the the underlying control so that I can set the VirtualMode property?

I'm running 2.1.3 if it matters.

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: WPF ListView control that using VirtualMode

Post by Support Team » Mon Sep 14, 2009 5:52 pm

domperez wrote:Does Ranorex provide access the the underlying control so that I can set the VirtualMode property?
Currently, this is not supported for WPF controls, sorry.

However, there are a few things you can do to speed up the automation. First of all, you can disable computationally expensive attributes (Cell.RowIndex, Column.Index, Row.Index) for WPF elements. Just use the following line of code in the initialization of your Ranorex code:
Ranorex.Plugin.WpfFlavor.Instance.ExpensiveAttributesEnabled = false;
The other possible improvements are Ranorex code improvements. Try to get all rows in your list view just once and then work through these row instances like in the following code:
IList<Ranorex.Row> rows = listView.Find("row");
foreach (Ranorex.Row row in rows)
{
    row.EnsureVisible();
    // get content from row...
}
You can also try to wrap the code accessing the rows inside a cache session. That way all attributes will be retrieved only once directly from the control and on all following calls the values are taken from the cache:
using (new Ranorex.Core.CacheSessionContext())
{
    // put your code accessing the ListView in here
}
It would certainly help if you could post your Ranorex code, then I might be able to give you some additional optimization hints.

Regards,
Alex
Ranorex Support Team
.
Image

domperez
Posts: 6
Joined: Tue Oct 30, 2007 4:23 pm

Re: WPF ListView control that using VirtualMode

Post by domperez » Tue Sep 22, 2009 10:29 pm

Code: Select all

Ranorex.Plugin.WpfFlavor.Instance.ExpensiveAttributesEnabled = false; 
Sorry for the slow followup but that did the trick. Is there anyway I can set that in Ranorex Spy so it doesn't choke on those controls?

Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: WPF ListView control that using VirtualMode

Post by Support Team » Fri Sep 25, 2009 10:20 am

Currently, there is no configuration parameter for that property which you could edit in a config file. However, you have the possibility to create a very small Ranorex plugin that does the trick. I attached such a plugin to this post. A detailed ReadMe.txt file is included that tells one how to use the plugin.

Regards,
Alex
Ranorex Support Team
SimplePlugin.zip
Simple plugin allowing to set Ranorex configuration properties that are only accessible through code
(4.28 KiB) Downloaded 443 times
Content of Readme.txt from SimplePlugin.zip:

Code: Select all

  RANOREX SIMPLE PLUGIN
~~~~~~~~~~~~~~~~~~~~~~~~~

Description:
This plugin provides a way to set configuration parameters for Ranorex Tools that are only accessible through code.

Installation:
1. Edit the SimplePlugin.cs file and add your custom Ranorex configuration code at the specified extension point.
2. Compile the project using Ranorex Studio or Visual Studio.
3. Copy the compiled DLL "Ranorex.Plugin.Simple.dll" to the following directory on your machine:
   "C:\Documents and Settings\All Users\Application Data\Ranorex2\Plugins"

If the installation succeeded, your configuration parameters should now be set for every Ranorex application.
.
Image