Hi
I need to capture the column widths and store them so that when I open the application the next time, I can restore the same column widths. How can I capture the column width when resized? Is there an event?
Thanks,
Lala
Hello Lala,
The Width property of the Field is not actually changed by the user action to resize it. The properties that are affected are the LabelWidthResolved and CellWidthResolved properties, as mentioned above. I would recommend checking e.PropertyName for these two properties and then get the value of them to essentially get the Width of your Field. If you would like, you could also then push the value of these LabelWidthResolved or CellWidthResolved properties to the Width property of your Field by setting the Field.Width property to the value of the property that changed.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
A google search found me the same answer on an old infragistics post. I tried to implement the same. When I iterate through the fields of the grid, I am not geting the new column width. I still get the old column width. Is it the Width property or something else that gives me the new width?
There currently does not exist an exclusive "FieldWidthChanged" type of event in the XamDataGrid's public API, but each Field in the XamDataGrid does expose a PropertyChanged event that will fire when that particular Field resizes. Depending on how the user resizes the field will determine which property this particular event fires for. For example, this PropertyChanged event's arguments contains a PropertyName property (e.PropertyName). If the user resizes the Field by resizing the Header, this event will fire for the "LabelWidthResolved" property. If the user resizes the Field by resizing one of the cells that belong to that Field, this event will fire for the "CellWidthResolved" property.
I would recommend that you handle this PropertyChanged event for your Fields and make an if check for e.PropertyName.Contains("LabelWidth") || e.PropertyName.Contains("CellWidth"), as this will allow you to essentially catch when a Field has resized in the XamDataGrid.
If you would like to see a FieldResized event officially included as part of the XamDataGrid in a future version, I would recommend suggesting a new product idea for this feature at http://ideas.infragistics.com. This product ideas site will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.