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.
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,AndrewAssociate Developer
Thanks so much. It works! Thanks.
You're welcome. I am glad that the PerformAutoSize method of the XamDataGrid fields helps you to resolve this issue.
Please let me know if you have any other questions or concerns on this matter.