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

  • Home
  • SEARCH
  • 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 7178973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:02:23+00:00 2026-05-28T17:02:23+00:00

I use EF and WPF to create application that shows me customer data and

  • 0

I use EF and WPF to create application that shows me customer data and allow me to edit this data. Datagrid show me phone numbers on the customer.

Yesterday I’ve changed my collections from CollectionViewSource to ListCollectionView because I wanted to filter them and sort.

    ((ISupportInitialize)mycollection).BeginInit();
    mycollection.CollectionViewType = typeof(ListCollectionView);
    ((ISupportInitialize)mycollection).EndInit();

But today I realized that there is no additional row for adding new objects if customer doesn’t have at least one phone number. Here are some screens for better view:

when tel exists

when tel doesn't exists

In both cases IsEnable and IsReadOnly does not change. 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-28T17:02:25+00:00Added an answer on May 28, 2026 at 5:02 pm

    When collection is empty, ListCollectionView doesn’t know what type of object it needs to add. There’s a solution to set type through reflection:

    public static void SetTypeToListCollectionView(Type t, CollectionViewSource collectionViewSource)
    {
        ListCollectionView repositoryView = (ListCollectionView)collectionViewSource.View;
    
        if (!repositoryView.CanAddNew)
        {
            ConstructorInfo ci = t.GetConstructor(new Type[] { });
            FieldInfo field = repositoryView.GetType().GetField("_itemConstructor", BindingFlags.Instance | BindingFlags.NonPublic);
            field.SetValue(repositoryView, ci);
        }
    }
    

    It’s working, but you need to do this before binding CollectionViewSource to DataGrid.ItemsSource

    I’ve did something like this, after setting type:

     BindingOperations.ClearAllBindings(dataGrid);
     BindingOperations.SetBinding(dataGrid, DataGrid.ItemsSourceProperty, new Binding() { Source = collectionViewSource });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use the WPF toolkit in a WPF application that I'm
I'm creating a WPF (in c#) application that will create html files based on
I'm a newbie in WPF applications. I want to create a application that displays
Ok so I'm developing a WPF application that makes heavy use of SQL Server.
I have a WPF application that allows users to create questions of all different
I'm planning a WPF application which will be able to create dynamic data entry
Greetings, As I create WPF application I obviously use lots of bindings. However I
I want to use WPF windows in a legacy win32 application. I'd like to
I use a WPF Toolkit Datagrid with a LINQ to SQL <my:DataGrid AutoGenerateColumns=False Name=dataGrid2>
Can I use the WPF DataGrid control in the same way I use a

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.