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
200
XamDataGrid column does not auto size correctly when the data switch from exponential to decimal
posted

Here is my case, with using XamDataGrid, my initial data is with exponential format. the column size fits the data width correctly. But when I change the data to decimal format which make the data width longer, but the grid column does not adjust accordingly. below is the screen shot:

The initial column width is ok with exponential format data:

Then, I switch the data to decimal format, the first age data became longer, but the column did not change to show the data:

Then I manually drag the border of the column, the whole data shown up:

By the way, I've attached my sample code project, please help me, any comments will do me big favor, thanks.

DataGrid_FieldSize.zip
Parents
  • 34430
    Offline posted

    Hello Yaron,

    The Fields in the XamDataGrid will resize upon entering and exiting edit mode, or if the actual value of the Field changes, but unfortunately, I don't believe that the auto-resize triggers when the underlying editor's Mask changes. To get this auto-size to happen, you can call the PerformAutoSize method on the Field that you wish to resize after the Mask changes.

    Knowing this, I would recommend hooking into the Checked event of your RadioButton elements and calling the following code, where "xdg1" is the XamDataGrid:

    xdg1.FieldLayouts[0].Fields["Age"].PerformAutoSize();

    It is possible that there may be a timing issue with this, as the resize may fire prior to the display text of the cells actually changing, and if this is the case, I would recommend trying the above code inside of a Dispatcher.BeginInvoke(new Action(() => { above code here })); This should delay the resize just enough for the display text to change and the resize to take effect.

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

Reply Children