Resizing a cell in a Silverlight datagrid column?
1 answer
Since I can't seem to find this solution on SO I'll be typing here.
You need to find the EVENT which is causing your string to be the wrong size. In my case, it's just scrolling up and down (but I've seen this on several different types of events). Here is the code to resize the datagrid:
/// <summary>
/// Reset datagrid row height
/// </summary>
/// <param name="row"></param>
public void ResetRowHeight(DataGrid grid, DataGridRow row)
{
// only for autosize rows
if (!double.IsNaN(row.Height)) return;
// store current rowheight
double rowheight = grid.RowHeight;
// fore recalculating row height
grid.RowHeight = 0;
row.UpdateLayout();
// restore rowheight
grid.RowHeight = rowheight;
row.UpdateLayout();
}
Where grid is your datagrid and row is the row that needs to be reset.
Now, just find the event that is causing your problem and it should be.
0
a source to share