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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:17:50+00:00 2026-05-30T23:17:50+00:00

I have a model composed of three classes: A, B and C. A has

  • 0

I have a model composed of three classes: A, B and C.
A has an ObservableCollection of B, B has an ObservableCollection of C.
C has a reference (not observable.. I don’t think is needed) to its parent (B), and B has a reference to A.
Each attribute of A, B and C notifies its changes.

I then have a Model class which “keeps track” of all the objects allocated. So it has an ObservableCollection of A, of B and of C (the only one that is required is for the As; I keep the lists for B and C only for faster reference).

My UI has a custom control: it has a ViewModel. The view has a list. Its ItemSources is bound to its ViewModel to an observablecollection named sensors. This ObservableCollection is of RowViewModel. Each RowViewModel keeps a reference to a C object.

My application loads the Model (creating A, B, C objects) and then sets the list of the view by calling this method (maybe this is the problem?)

public void setSensors(IList<C> list)
        {
            this.sensors.Clear();
            if (list != null)
            {
                foreach (var row in list)
                    this.sensors.Add(new RowViewModel(row));
            }
        }

The problem is that if I modify a property of my C object, this is not reflected on the UI.

Someone can help me?
Thank you

Francesco

EDIT: (SOLVED)
thanks to your answers I checked my code and changed one thing: instead of binding my UI element to its ViewModel (and the viewModel simply “redirect” the call to the model property), I directly bind the UI to the real property, and it works!!
So… in MVVM I cannot use “shortcuts”??.. or if I use them I should register for notification of the property and “propagates” them?

  • 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-30T23:17:51+00:00Added an answer on May 30, 2026 at 11:17 pm

    I think your UI isn’t updated, because it’s binded to RowViewModel object, not to C. So, you should subscribe to PropertyChanged event of C in your RowViewModel‘s constructor, and notify about those changes through RowViewModel.PropertyChanged. By the way, can you provide an example of binding in your UI?

    UPDATED:

    An example of “proxying” PropertyChanged event:

    public class Model: INotifyPropertyChanged
    {
      private string _YourProperty;
      public string YourProperty
      {
        get { return _YourProperty; }
        set
        {
          if (_YourProperty == value) return;
          _YourProperty = value;
          RaisePropertyChanged("YourProperty");
        }
      }
    
      public event PropertyChangedEventHandler PropertyChanged;
    
      private void RaisePropertyChanged(string propertyName)
      {
        if (PropertyChanged != null)
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
    }
    
    public class ViewModel: INotifyPropertyChanged
    {
      private Model _Model;
    
      public ViewModel(Model model)
      {
        _Model = model;
        _Model.PropertyChanged += OnModelPropertyChanged;
      }
    
      public string YourProperty
      {
        get { return _Model.YourProperty; }
      }
    
      private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e)
      {
        if (e.PropertyName == "YourProperty")
          RaisePropertyChanged("YourProperty");
      }
    
      public event PropertyChangedEventHandler PropertyChanged;
    
      private void RaisePropertyChanged(string propertyName)
      {
        if (PropertyChanged != null)
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
    }
    

    You can read also http://george.softumus.com/2011/10/inotifypropertychanged-and-magic.html – how to avoid using “magic strings” (hardcoded constants) as property names.

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

Sidebar

Related Questions

I have model Foo which has field bar. The bar field should be unique,
I have model Article it has field title with some text that may contain
I have a model, Thing, that has a has_many with ThingPhoto, using Paperclip to
I have a model named UserPrice which has the attribute :purchase_date (a date_select) in
I have the following classes in my JPA model (getters, setters, and irrelevant fields
I have a data model, composed mostly of an NSMutableArray 'contents' and NSMutableDictionary 'contentsByName'.
I have a 3D model, composed of triangles. What I want to do is,
I find myself needing to have a View expose its Model and Controller references.
I have a table with a primary key composed of three columns: CODE_TARIF, UNITE,
Lets say I have model inheritance set up in the way defined below. class

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.