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 1054449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:24:31+00:00 2026-05-16T17:24:31+00:00

I bind a collection ObservableCollection<Foo> to a dependency property on my controller, but I

  • 0

I bind a collection ObservableCollection<Foo> to a dependency property on my controller, but I run it through an IValueConverter to make it ObservableCollection<object> instead, which is what my controller expect. The conversion works fine – I create an ObservableCollection<object> and fill it with all the Foo’s from the original list. This however brings a problem which is that now I’m observing on the collection created in the value converter, and hence doesn’t see any of the changes to the original collection.

So; do I have to hook up eventhandlers in the converter to manually keep the converted collection in sync with the original one, or is there a better way to handle this? I guess I can’t do the convertion without actually creating a new collection? Or can I do the binding in some clever way such that I don’t have to do the convert?

  • 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-16T17:24:31+00:00Added an answer on May 16, 2026 at 5:24 pm

    I don’t know if it helps, but often in a ViewModel, I declare IList or another less specific interface as the property type instead of a specific one.

    Then I can bind quasi all collections and lists to this propery.

    While the property is set, I check if it Implements INotifyPropertyChanged and if yes, I attach an CollectionChanged-EventHandler. When the property has changed newly, I remove the EventHandler from the old INotifyPropertyChanged (if it was).

    The drawback of this is, that the ViewModel must be prepared to see objects other types than expected. But this is normally a simple job.

    void YourDPValueChanged(DependencyPropertyChangedEventArgs e) {
        INotifyCollectionChanged newCollection = e.NewValue as INotifyCollectionChanged;
        INotifyCollectionChanged oldCollection = e.OldValue as INotifyCollectionChanged;
        if (null != newCollection) {
            newCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
        }
        if (null != oldCollection) {
            oldCollection.CollectionChanged -= new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I bind my object collection to CheckedListBox items with IsChecked property? Here
I have a collection ObservableCollection<Foo> , and I want to bind this to a
i need to bind a collection of objects to a combo box which i
I have the following collection which i would like to bind to a combobox:
I have a wpf control named DataPicker which has a dependency property named SelectedDate.
I am trying to bind a property ObservableCollection<ObservableCollection<Location>> to a ListBox with ItemTemplate of
Should one bind DataGrid to the ICollectionView = CollectionViewSource.GetDefaultView(collection) or to the ObservableCollection<T> collection;
I have a datagrid that's bound to an observablecollection object. The collection may be
I have this ListBox which is bound to an ObservableCollection. Each object in the
I have a Observable collection which is bind to listview which contains date and

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.