Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Custom Type Descriptors could be used to solve this problem. Before you bind to a Position, your type descriptor could kick in, and provide get and set methods to temporarily build the values. When the changes are committed, it could build the immutable object. </p> <p>It might look something like this:</p> <pre><code>DataContext = new Mutable(position, dictionary =&gt; new Position(dictionary["lattitude"], ...) ); </code></pre> <p>Your bindings can still look like this:</p> <pre><code>&lt;TextBox Text="{Binding Path=Lattitude}" /&gt; </code></pre> <p>Because the Mutable object will 'pretend' to have properties like Lattitude thanks to its TypeDescriptor. </p> <p>Alternatively you might use a converter in your bindings and come up with some kind of convention. </p> <p>Your Mutable class would take the current immutable object, and a <code>Func&lt;IDictionary, object&gt;</code> that allows you to create the new immutable object once editing completes. Your Mutable class would make use of the type descriptor, which would create PropertyDescriptors that create the new immutable object upon being set. </p> <p>For an example of how to use type descriptors, see here:</p> <p><a href="http://www.paulstovell.com/editable-object-adapter" rel="noreferrer">http://www.paulstovell.com/editable-object-adapter</a> </p> <p><strong>Edit</strong>: if you want to limit how often your immutable objects are created, you might also look at BindingGroups and IEditableObject, which your Mutable can also implement. </p>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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