Page 1 of 1

Silverlight: How to access rows/columns in Datagrid

Posted: Fri Jul 22, 2011 8:28 pm
by rekha1234
Hi,

I am new to Ranorex and Automating Silverlight applications. I am supposed to automate clicking on a row in the the Datagrid based on its column value. Below are some details of the Datagrid

Ranorex Path: /dom[@domain='00.00.000.00']/body/form/div[@id='silverlightControlHost']/object/form/tabpagelist[6]/tabpage/table[@automationid='dg_Files']

AutomationID: dg_Files
ClassName:DataGrid
Frameworkid:Silverlight
IsContentElemet True
IsControlElement True

Can someone please guide me on how to instantiate the data grid and access elements in that

Re: Silverlight: How to access rows/columns in Datagrid

Posted: Mon Jul 25, 2011 11:44 am
by Support Team
Hi,

Please could you post us a Ranorex Snapshot of the DataGrid. With this snapshot it is much easier to analyze your issue.
How to create a Ranorex Snapshot

Thanks in advance.

Regards,
Peter
Ranorex Team

Re: Silverlight: How to access rows/columns in Datagrid

Posted: Mon Jul 25, 2011 7:52 pm
by rekha1234
Hi Peter,

Thanks for replying. Please find the snapshot attached as requested

Re: Silverlight: How to access rows/columns in Datagrid

Posted: Tue Jul 26, 2011 3:33 pm
by Support Team
rekha1234 wrote:Can someone please guide me on how to instantiate the data grid and access elements in that
From the snapshot this task looks pretty straight forward. Ranorex does not identify the cells correctly as such (they only show up as "Element", not as "Cell"), but still you can get to all data within them.
The children of the "RowsPresenter" element represent the rows in the datagrid, i.e. the elements with name "System.ComponentModel.CheckableItem...". The children of the elements representing the rows are the actual cells of the grid, again containing elements for the content of the cells. Your code could look like the following:
Ranorex.Table table = "pathToTable";
IList<Ranorex.UIAutomation> rows = table.Find<UIAutomation>(
    "element[@automationid='RowsPresenter']/element");
// get cells of first row
IList<Ranorex.UIAutomation> cellsInFirstRow = rows[0].Find<UIAutomation>("element");
Regards,
Alex
Ranorex Team

Re: Silverlight: How to access rows/columns in Datagrid

Posted: Fri Jul 29, 2011 8:52 pm
by rekha1234
Thanks alot for the Reply. Suggested code worked!!

Regards,
Rekha