Note that there are some explanatory texts on larger screens.

plurals
  1. PONotified property not "updated" in the UI
    primarykey
    data
    text
    <p>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.</p> <p>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).</p> <p>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.</p> <p>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?)</p> <pre><code>public void setSensors(IList&lt;C&gt; list) { this.sensors.Clear(); if (list != null) { foreach (var row in list) this.sensors.Add(new RowViewModel(row)); } } </code></pre> <p>The problem is that if I modify a property of my C object, this is not reflected on the UI.</p> <p>Someone can help me? Thank you</p> <p>Francesco</p> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload