Hi,
I'd need to implement an option in a context menu that resizes a field in a way that all cell values are fully visible.
How could this be done?
Best
Oliver
Hello Oliver,
Thank you for your post!
Fields in the XamDataGrid have a method named PerformAutoSize, which will resize the field to the largest cell value. By creating an implicit Style for LabelPresenter, you can apply a ContextMenu to the header of each XamDataGrid field, as the LabelPresenter represents the header of a field. Then, by using a command on a "Resize" menu item in your context menu and passing in the menu item itself to the command as a parameter, you can create the functionality to resize the field. MenuItem.Parent will give you the ContextMenu, and in this case, ContextMenu.PlacementTarget will give you the LabelPresenter. The LabelPresenter has a Field property associated with it which will return the field it is the header of, so by using LabelPresenter.Field.PerformAutoSize(), you can resize a XamDataGrid field via a context menu.
I have attached the sample project to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Thanks, this worked.