Hi,
I've configured the XamDataGrid to have a Group By Area at the top and collapsed by default. When a user tries to remove a field by dragging it out of the grid, because the field got dragged over the Group By Area expander, the Group By Area got expanded. Is there a way to disable that auto-expansion behavior?
Thanks,
Harold
Hello Harold,
Thank you for the grouping details you have provided.
When the GroupByArea is visible and present, in order to disable the expansion behavior, you can handle the Expanded event of the GroupByAreaMulti element by setting its IsExpanded property to false.
private void dataGrid_Loaded(object sender, RoutedEventArgs e){ dataGrid.GroupByAreaMulti.Expanded += (se, ev) => { (se as GroupByAreaMulti).IsExpanded = false; };}
In order to disable the grouping functionality of the XamDataGrid, you can set the FieldSettings.AllowGroupBy property of the XamDataGrid to false.
dataGrid.FieldSettings.AllowGroupBy = false;
I have attached a sample application that demonstrates the approach from above.
If you have any questions, please let me know.
Hi Tacho,
Thanks for the quick response. But your solution is not what I'm looking for. I want to see if there's a way to not expand the group by area when a field is dragged over the group by area. I still want to be able to expand the group by area by clicking on the expander. The Expanded event handler you suggested will simply not allow the group by area to be expanded.
Thank you for the feedback.
I am glad to know that I was able to help you achieve the functionality you were looking for. I believe this thread can help other people looking for a similar solution.
Thanks Tacho!
In order to disable the expansion behavior only when a field is dragged over the GroupByAreaMulti element, I can suggest you perform an explicit check inside the Expanded event for whether or not the expander bar has been clicked. If it has not been clicked (this means we are dragging a field), we can disable the expansion.This approach will require an additional flag that will return true if the expander button has just been clicked.
I have attached a sample application that demonstrates the approach from above.If you have any questions, please let me know.