Silverlight: How to access rows/columns in Datagrid

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
rekha1234
Posts: 6
Joined: Fri Jul 22, 2011 8:12 pm

Silverlight: How to access rows/columns in Datagrid

Post by rekha1234 » Fri Jul 22, 2011 8:28 pm

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
Attachments
Untitled.png
Untitled.png (43.74 KiB) Viewed 2513 times

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

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

Post by Support Team » Mon Jul 25, 2011 11:44 am

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
.
Image

rekha1234
Posts: 6
Joined: Fri Jul 22, 2011 8:12 pm

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

Post by rekha1234 » Mon Jul 25, 2011 7:52 pm

Hi Peter,

Thanks for replying. Please find the snapshot attached as requested
Attachments
DataGridSnapshot.rxsnp
snapshot
(442.94 KiB) Downloaded 241 times

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

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

Post by Support Team » Tue Jul 26, 2011 3:33 pm

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
.
Image

rekha1234
Posts: 6
Joined: Fri Jul 22, 2011 8:12 pm

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

Post by rekha1234 » Fri Jul 29, 2011 8:52 pm

Thanks alot for the Reply. Suggested code worked!!

Regards,
Rekha