Home Forums WPF controls Xceed DataGrid for WPF Group By question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #25013 |

    I have been playing around with the DataGrid and it is cool. However, the DataGrid is acting a little strange. When the application starts I bind the DataGrid to a LINQ query, and I create a BindingListCollectionView from CollectionViewSource.GetDefaultView() and then add GroupDescriptions to it, and bind that to a ListView. The DataGrid picks up the GroupDescriptions, but I don’t understand why?

    The following is the XAML:

    <xcdg:DataGridControl x:Name=”ListViewMeetings” HorizontalAlignment=”Stretch” VerticalAlignment=”Stretch”/>

    <ListView x:Name=”ListViewMeetings2″ IsSynchronizedWithCurrentItem=”True” Grid.Column=”1″/>

    The following is the code behind that binds to a LINQ query:

    CaselinkDataContext dc = new CaselinkDataContext();
    var cases = (
    from c in dc.Cases
    where c.asset == “N”
    from m in c.Meetings
    where m.time_341 != “”
    orderby m.date_341, m.time_341, c.case_no
    select new { m.date_341,m.time_341,m.rank_341,c.trustee_no,c.case_no,c.case_name,m.result_341,c.debt_atty,c.d_rnd,c.date_cont,c.date_closed,c.d_discharge }

    BindingListCollectionView cv = CollectionViewSource.GetDefaultView(cases) as BindingListCollectionView;

    cv.GroupDescriptions.Add(new PropertyGroupDescription(“date_341”));

    ListViewMeetings.ItemsSource = cases;
    ListViewMeetings2.ItemsSource = cv;

    Imported from legacy forums. Posted by Wally (had 399 views)

    Xceed Support
    Post count: 5658

    It is possible the CollectionViewSource.GetDefaultView( cases ) returns a CollectionView that is synchronized with the cases data structure…

    I suggest trying to wrap the cases assigned to the DataGridControl with a DataGridCollectionView, which maintain its own grouping/sorting.

    ListViewMeetings.ItemsSource = new DataGridCollectionView( cases );

    Imported from legacy forums. Posted by Marcus [Xceed] (had 2608 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.