Skip to main content

Microsoft Silverlight

Answered Question How to retrieve an item inside a DataGridRowRSS Feed

(0)

Ors84bs
Ors84bs

Member

Member

31 points

90 Posts

How to retrieve an item inside a DataGridRow

Hi,

i'd like to get the item contained inside a particular row of a silverlight datagrid.

How could I do?

 Thank you very much

tanmoy.r
tanmoy.r

Contributor

Contributor

3594 points

710 Posts

Answered Question

Re: How to retrieve an item inside a DataGridRow

 MyClass item = MyDataGrid.ItemsSource.Cast<MyClass>().Where((_, pos) => pos == row_number).SingleOrDefault();
  Assuming your DataGrid item source is a collection of MyClass class

You might need to add  System.Linq; namespace.

Please Mark as Answer if this helps you.
Thanks n Regards
~Tanmoy
Blog: http://anothersilverlight.blogspot.com/

Brian Braeckel
Brian Br...

Member

Member

368 points

66 Posts

Answered Question

Re: How to retrieve an item inside a DataGridRow

If you want the nth item inside the DataGrid, then you can grab it from the ItemsSource as suggested above.  If you have an actual DataGridRow element, though, you can get the associated item from its DataContext.

yifung
yifung

Contributor

Contributor

3313 points

540 Posts

Microsoft
Answered Question

Re: How to retrieve an item inside a DataGridRow

Also, if you have an element within a Row, like a button, and you're using Silverlight 3, you can call the new static method DataGridRow.GetRowContainingElement.  This method is in the newer builds of Silverlight 3, and I do not believe it is in the Beta build of Silverlight 3.

Yifung Lin [MSFT]

Ors84bs
Ors84bs

Member

Member

31 points

90 Posts

Re: Re: How to retrieve an item inside a DataGridRow

 Thank you very much

You solved my problem

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities