This project has moved and is read-only. For the latest updates, please go here.

GroupDescription causing crash if in CollectionViewSource

Oct 6, 2015 at 11:56 AM
Edited Oct 6, 2015 at 11:58 AM
So I seem to be creating a bug, but I'm not sure if it is really a bug or just down to how I have done things. The scenario is that the grouping works, sorting works but if you take the "Date" column header and drag it up to the grouping row where "Hour" already exists, it crashes complaining that the grouping already exists rather than detecting that it's already there.

If you take the grouping away from the CollectionViewSource, it no longer groups until you drag the "Date" column header up, but having the grouping by default is the desired view.

I have the following in my CollectionViewSource:
        <scm:SortDescription PropertyName="Hour" Direction="Descending" />
        <scm:SortDescription PropertyName="MessageTime" Direction="Descending" />
        <xcdg:DataGridGroupDescription PropertyName="Hour" />
And then the following against the WPF DataGrid:
    <xcdg:Column FieldName="ReversedTime" Title="Date" Width="140" IsMainColumn="True">
            <xcdg:DataGridGroupDescription PropertyName="Hour" />
But I do not actually show MessageTime. ReversedTime and Hour are both just properties for manipulating MessageTime:
return messageTime.ToString("yyyy-MM-dd HH:00");

return messageTime.ToString("yyyy-MM-dd HH:mm:ss.ffff");
Oct 7, 2015 at 12:54 PM

Can you submit a sample so we can test the exact same scenario ? I'm not sure what the "Date" column is.
Oct 8, 2015 at 10:27 AM
I'll try and get a sample together but it's my son's birthday tomorrow and last day of work plus out tonight so probably be next week before I can..

Put simply, all roads lead to MessageTime which is the date time property. Both Hour and ReversedTime are read-only properties that refer to MessageTime. As you can see, whilst I'm displaying ReversedTime with a title of Date, I told it that the grouping was to be on Hour which matches with the collectionviewsource's own grouping. However, I don't think there is a check done or because I've initiated them explicitly in both cases and not using a shared resource, it ends up trying to add a second Hour grouping which causes the crash.