Hi,
I've found a very strange thing in XamDataGrid in connection with its grouping behaviour.(I've created a simple sample and I've attached it to this post.)The problem is the following. When I use the default controls to group the records by one of the fields the Grouping and Grouped events occur properly. But for example if I group by code those events don't occur.
Run my sample and try this: Open the group header and click one of the buttons above it. The group header will be changed and the records will be grouped but the events will not be fired. After it abolish the grouping by pulling down the sorted field and see that those events will be fired.
The code:
<Window x:Class="XamDataGridEditor.Window1"xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:x=http://schemas.microsoft.com/winfx/2006/xamlTitle="Window1" Height="300" Width="300" xmlns:igDP="http://infragistics.com/DataPresenter"><StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="Group by PropertyName" Click="ButtonPropertyName_Click" /> <Button Content="Group by PropertyValue" Click="ButtonPropertyValue_Click" /> </StackPanel> <igDP:XamDataGrid Name="xamDataGrid1" /></StackPanel></Window>
void xamDataGrid1_Grouping(object sender, GroupingEventArgs e){Console.WriteLine("xamDataGrid1_Grouping occurs");}
private void ButtonPropertyName_Click(object sender, RoutedEventArgs e){xamDataGrid1.FieldLayouts[0].SortedFields.Clear();FieldSortDescription sort = new FieldSortDescription();sort.Direction = ListSortDirection.Descending;sort.FieldName = "PropertyName";sort.IsGroupBy = true;xamDataGrid1.FieldLayouts[0].SortedFields.Add(sort);}
private void ButtonPropertyValue_Click(object sender, RoutedEventArgs e){xamDataGrid1.FieldLayouts[0].SortedFields.Clear();FieldSortDescription sort = new FieldSortDescription();sort.Direction = ListSortDirection.Descending;sort.FieldName = "PropertyValue";sort.IsGroupBy = true;xamDataGrid1.FieldLayouts[0].SortedFields.Add(sort);}
I think this is not normal.Have anybody seem that before? I would be glad if anybody had any suggestions.
Best regards,atus
Hello Atus,
Thank you for your post. I have been looking through it and I can say that this is normal, because our controls doesn’t fire their events if the action is done by code. If so, you can execute the desired code after the action you perform. This is like a pattern for custom controls, which is used to have better performance. Please note, we are making efforts to ensure all posts are addressed by an Infragistics expert. We believe that the other community members could benefit from this thread as well.
Feel free to write me if you need further assistance.