Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 773429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:57:47+00:00 2026-05-14T18:57:47+00:00

I want to do something that I thought would be very simple. I want

  • 0

I want to do something that I thought would be very simple. I want to bind a generated Entity Framework EntityCollection to a WPF DataGrid. I also want this grid to be sortable.

I have tried all kinds of things to make this happen, including using a CollectionViewSource. However, nothing seems to work. Using a normal CollectionViewSource around the EntityCollection gives me:

'System.Windows.Data.BindingListCollectionView' view does not support sorting.

Ok…strange. I would have thought this would work. Next on the CollectionViewSource, I try setting:

 CollectionViewType="ListCollectionView"

Great, sorting now works. But wait, I can’t add or remove entities using the grid now, presumably because ListCollectionView doesn’t support this with an entity framework context.

So, I guess I need to capture events coming out of the datagrid in order to add or remove entities manually from my context. Now I can’t find an event to capture to detect an add…!

Why is this so hard? This should be the standard “demo” case that Microsoft should have designed around.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:57:48+00:00Added an answer on May 14, 2026 at 6:57 pm

    BindingListCollectionView is not directly the problem. See ‘System.Windows.Data.BindingListCollectionView’ view does not support sorting on Microsoft Connect for details why it does not support sorting.

    On the other hand ListCollectionView supports sorting obviously using a different technique.

    I have also tried the following code and it worked beautifully. I have basically implemented your XAML from the other post in code.

     DatabaseContext.ObjectStateManager.ObjectStateManagerChanged += (o, args) => Debug.WriteLine(args.Element.ToString());
    
     var collectionViewSource = new CollectionViewSource();
     ((ISupportInitialize)collectionViewSource).BeginInit();
     collectionViewSource.CollectionViewType = typeof (ListCollectionView);
     collectionViewSource.Source = ((IListSource) DatabaseContext.Survey).GetList();
     collectionViewSource.SortDescriptions.Add(new SortDescription {PropertyName = "Name"});
     ((ISupportInitialize)collectionViewSource).EndInit();
    
     var editableCollectionView = (IEditableCollectionView)collectionViewSource.View;
     var survey = editableCollectionView.AddNew();
    
     // Before this point ObjectStateManager event has occurred and Debug Output is written to.
    
     editableCollectionView.CommitNew();
     DatabaseContext.SaveChanges(); // THIS WORKS TOO!
    

    My DatabaseContext.Survey is an ObjectQuery<Survey>. Are you showing an ObjectQuery or a Linq-to-EF query? The former obviously works for me. The latter is where I see a problem. That is not supposed to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set layout something like What i thought that i will have
I am trying to do something I thought would be relatively simple and get
I'm attempting to solve what I thought would be a very simple problem. I
I am trying to do something very simple. I want to display the video
I want something that will receive me the processes details, like I receive with
I am not even sure how to ask this question. I want something that
I want to make something that makes much sense, but I think its not
this is something that i don't want to program, but i was looking for
I want something to put in my .htaccess file that will hide the .php
Q1. I want to grep something like that: grep -Ir --exclude-dir=some*dirs my-text ~/somewhere but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.