Page 1 of 1

WPF ListView control that using VirtualMode

Posted: Fri Sep 11, 2009 4:16 pm
by domperez
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

Re: WPF ListView control that using VirtualMode

Posted: Mon Sep 14, 2009 5:52 pm
by Support Team
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

Re: WPF ListView control that using VirtualMode

Posted: Tue Sep 22, 2009 10:29 pm
by domperez

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!

Re: WPF ListView control that using VirtualMode

Posted: Fri Sep 25, 2009 10:20 am
by Support Team
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
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.