How to get DataGridRow collection of Datagrid
Last post 05-09-2008 11:58 AM by aganariman. 2 replies.
Sort Posts:
05-07-2008 8:39 AM
How to get DataGridRow collection of Datagrid

Hi,

I'm trying to use TransformToVisual void of one of DataGridRows from my Datagrid. But can't get the collection of DataGridRows.

I want to pop up something near the selected row in a datagrid, to do so I need position of the datagridrow object in the browser;

Thanks. Hope that it isn't very difficult.

 

aganariman

Joined on 05-07-2008
Turkey
Posts 3
05-07-2008 3:09 PM
Marked as Answer
Re: How to get DataGridRow collection of Datagrid

1) Are you sure you do not want to use DataGrid.RowDetailsTemplate to achieve this? You can set DataGrid,RowDetailsVisibility="VisibleWhenSelected" and you can put any control in the RowDetailsTemplate.

2) If you do not want to use method 1. You can try to catch DataGrid.MouseLeftButtonDown event.

private void theGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

{

    Point p = e.GetPosition(null); // here is where you want to open the popup.

   DataGrid g = sender as DataGrid;

   g.SelectedItem  // this is the Data for that selected row.
 

}
 

 


Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

sladapter

Joined on 03-05-2008
Indiana, US
Posts 404
05-09-2008 11:58 AM
Re: How to get DataGridRow collection of Datagrid

Second solution is not very suitable for me because I do not want to pop up my other control on the point clicked, I need to pop up on a corner of datagridcell that was clicked. If I could get a DataGridCell o DataGridRow object that was clicked it will solve my problem(I will use visualtransform of clicked row or cell).

Now I found one way to add events to Datagridrows by adding them on RowPrepare event. And it solved my problem.

Thanks for your reply.

 

aganariman

Joined on 05-07-2008
Turkey
Posts 3