Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1240
Resizing Column Widths On Window Resize
posted

I'm trying to resize my column widths whenever the user resizes the window. When the window size changes, I determine the new column widths then apply it to the column and label width properties:

currColField.Settings.CellMinWidth = dWidthPerCol;
currColField.Settings.CellMaxWidth = dWidthPerCol;
currColField.Settings.CellWidth = dWidthPerCol;

currColField.Settings.LabelMaxWidth = dWidthPerCol;
currColField.Settings.LabelMinWidth = dWidthPerCol;
currColField.Settings.LabelWidth = dWidthPerCol;

Problem is, the settings don't take cause the columns to resize.  Am I doing something wrong?  Is there a better way to approach this?

Thanks
Dan

Parents
No Data
Reply
  • 8576
    Offline posted
    Hi Dan -
     
    The following code works for me (you would never want to do this but it demonstrates that you can resize cells when the containing window is resized):
     

    protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)

    {

    base.OnRenderSizeChanged(sizeInfo);

    double newCellWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].CellWidthResolved + 1;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMinWidth = newCellWidth;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMaxWidth = newCellWidth;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellWidth = newCellWidth;

     

    double newLabelWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].LabelWidthResolved + 1;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMaxWidth = newLabelWidth;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMinWidth = newLabelWidth;

    this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelWidth = newLabelWidth;

    }

    Joe
     
Children