Hi
On my project I have the following case of working with column sizes:
1. On the first load of the grid column should autosize its width to fit the data in its cells
2. If data changes and it needs more space than column should be resized to fit the data
3. If data changes and it needs less space than column should not be resized
4. If user changes the width of the column than I should save its width and disable column resizing mechanism. (I have custom format for storing changed width of the columns)
I have an issue:
There is no difference between resizing of the column by grid (autosize) and resizing of the column by user.
How can I differentiate autosize and manual resizing?
Hello Michael,
I suggest you add the following check in the OnSizeChanged event:
void OnSizedChanged(object sender, SizeChangedEventArgs e){ if ((Utilities.GetAncestorFromType(sender as HeaderPresenter, typeof(DataRecordPresenter), true) as DataRecordPresenter).IsMouseOver == true) {
}}
Hope this helps you.
Hi Stefan,
This works partially but the event fires multiple times as the control is instantiated. Is there anyway of detecting if the size change is as a result of a user re-sizing the field rather than initialization of the control ?
I apologize for the late reply. As for your question I can say that you are not able to determine whether the resizing come from the user or from code, but are able to handle the HeaderPresenter’s SizeChanged event by creating a Style like this:
<Style TargetType="igDP:HeaderPresenter">
<EventSetter Event="SizeChanged" Handler="OnSizedChanged"/>
</Style>
And the following handler in your code behind:
void OnSizedChanged(object sender, SizeChangedEventArgs e) { }
Anybody feel like replying at Infragistics ??????
As of v11.2 there is still no XamDataGrid.FieldWidthChanged event. The XamDataGrid.SaveCustomizations method will persist the field widths but this is not much use if we cannot detect when the width has changed.
Is there any intention to add this event to the XamDataGrid or am I just not finding it ?
Thanks.