Note that there are some explanatory texts on larger screens.

plurals
  1. POBi-directional view model syncing with "live" collections and properties
    primarykey
    data
    text
    <p>I am getting my knickers in a twist recently about View Models (VM).</p> <p>Just like <a href="https://stackoverflow.com/questions/1256793/mvvm-sync-collections">this guy</a> I have come to the conclusion that the collections I need to expose on my VM typically contain a different type to the collections exposed on my business objects.</p> <p>Hence there must be a bi-directional mapping or transformation between these two types. (Just to complicate things, on my project this data is "Live" such that as soon as you change a property it gets transmitted to other computers)</p> <p>I can just about cope with that concept, using a framework like <a href="http://truss.codeplex.com" rel="nofollow noreferrer">Truss</a>, although I suspect there will be a nasty surprise somewhere within.</p> <p>Not only must objects be transformed but a synchronization between these two collections is required. (Just to complicate things I can think of cases where the VM collection might be a subset or union of business object collections, not simply a 1:1 synchronization).</p> <p>I can see how to do a one-way "live" sync, using a replicating ObservableCollection or something like CLINQ.</p> <p>The problem then becomes: What is the best way to create/delete items?</p> <p>Bi-directinal sync does not seem to be on the cards - I have found no such examples, and the only class that supports anything remotely like that is the ListCollectionView. Would bi-directional sync even be a sensible way to add back into the business object collection?</p> <p>All the samples I have seen never seem to tackle anything this "complex".</p> <p>So my question is: How do you solve this? Is there some technique to update the model collections from the VM? What is the best general approach to this?</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.
 

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