I have an editable field with XamNumericEditor, width is Auto and mask is rather long, about 17 digits., something like ###,###,###,###,#00.00. When a value is small enough to fit in a cell, all is okay. When I click in the cell, the whole column resizes to accommodate the whole mask. But When a number in a cell is big, the cell does not resize when the grid is displayed, higher digits are cut off and when I click in a cell, it does not resize, just scrolls the mask to the left and displays the last two digits on the left side of the cell and most of the cell is empty. I reckon the field needs resizing to make the whole number fit in, but still have an auto width. I tried calling PerformAutoSize on the problematic field, but it did not help. Anybody has an idea what to do? Thanks.
Ivan
Hello Ivan,
Thank you for your post. I have been looking into it and I can suggest you set the Field’s Width to Auto, so the cells could be resized automatically. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for your response. That's what I have done already and it works perfectly if the number in the cell fits. Try this: set mask/format to ###,###,###,###,##0.00, set the value for the cell in the second row in the viewmodel to let's say 123,123,123,123,123.23, set the label of the field to something short. What happens in my case is that the column is too narrow to display the whole number and it does not resize the column if I click into this cell to edit the number. It does resize it if I click in the same column where the whole number fits, let's say it has 0.00 in it in the first row. And then the column resizes and I see that big number complete as well and I can edit it as expected. To me it looks like the grid tries to get some default width, but it's not good enough and then it cannot fit the number in, which confuses the resizing logic.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
so your example works, I only had to change Mask= to Format=, but the resizing is okay. Probably I should have started with the following, but it did not seem important at the time. We use a derivative of XamNumericEditor and setting the Mask and Format properties in OnInitialized method of the editor. I am guessing it's too late then. We use a shortcut class NumericField, which is a derivative of Field with a few properties, so we can define a field as follows:
<NumericField Name="Age" Width="Auto" FormatType="DecimalSeparated" Label="Age" />
FormatType is an enum with predefined formatting that is then translated into Mask and Format during OnInitialized of the editor. Our editor is linked to the field using Settings.EditorType of the NumericField. So the question is, what is the earliest possibility to set those 2 properties before OnInitialized? Now the editor goes to Host (CellValuePresenter) and then to Field (cast to NumericField) to access the FormatType. Maybe it can be done sooner from the Field end and not editor's?
I am glad that you were able to resolve your issue with the resizing. As for your other question, I am not completely sure that I understand your requirement, but I can say that there is no event that fires earlier that you can use to set the properties you want.
I extracted my classes and used them in your example and it still works fine. So I guess the problem is anything added to the grid in our application. I will have to concentrate on that and I think we can close this conversation. Thank you for your help.