none
Loop Through DataGrid Rows

Answers

  • Hi:

      If you use DataTemplate you can try to put a StackPanel in it and adjust the height and width in it's Loaded event handler. You can refer to my reply in these posts:

    http://silverlight.net/forums/p/11614/38274.aspx#38274

    http://silverlight.net/forums/p/12818/42506.aspx#42506

      If you use auto generated columns the row style will be idential for each row. I think it's difficulty to achieve this (column width can be "autosized" by retrieving data directly from data source).

      If you use auto generated columns and the data source is unknown at design time I think you have to use reflection to get the length of each properties.

    Regards

     

    Monday, March 31, 2008 9:23 PM
  • Hi:

      As far as I know it's by design. The DataGrid may contain thousands of items. This feature can help to save memory.

    Regards

    Wednesday, April 02, 2008 1:41 AM

All replies

  • Hi:

      As far as I know it's not supported yet. Could you tell us your requirement? Maybe we can give you a workaround.

    Thanks

    Monday, March 31, 2008 1:24 AM
  • Hey,

      My primary goal is to come up with a way to "autosize" the row height and column width.  If you have a workaround for this, it would be greatly appreciated. 

    Another reason for accessing the rows in the datagrid is to get a rowcount. 

    Thanks. 

     

    Monday, March 31, 2008 9:55 AM
  • Hi:

      If you use DataTemplate you can try to put a StackPanel in it and adjust the height and width in it's Loaded event handler. You can refer to my reply in these posts:

    http://silverlight.net/forums/p/11614/38274.aspx#38274

    http://silverlight.net/forums/p/12818/42506.aspx#42506

      If you use auto generated columns the row style will be idential for each row. I think it's difficulty to achieve this (column width can be "autosized" by retrieving data directly from data source).

      If you use auto generated columns and the data source is unknown at design time I think you have to use reflection to get the length of each properties.

    Regards

     

    Monday, March 31, 2008 9:23 PM
  • Hey,

    This looks like it's going to work.  My problem now is that the length of my text and the width of the datagrid column aren't converting.  Do you have a formula to get the pixel size of a char based on font and font size?

    Tuesday, April 01, 2008 4:09 PM
  • Hey, i figured it out.  Your code example worked fine.  I have one more question...

     The StackPanel_Loaded event fires every time i try to scroll down the datagrid.  This brings my app to a crawl.  Is there any way of doing this when the datagrid loads?

     

    Thanks.

    Tuesday, April 01, 2008 5:11 PM
  • Hi:

      As far as I know it's by design. The DataGrid may contain thousands of items. This feature can help to save memory.

    Regards

    Wednesday, April 02, 2008 1:41 AM
  • Hi,

    Thanks for your help.

    Wednesday, April 02, 2008 9:14 AM