Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You appear to be creating a <em>new</em> Customer object that is not in your <em>ObservableCollection</em></p> <pre><code>tempCustomerobj = new Customer(c); </code></pre> <p>and then editing that <em>new</em> object.</p> <pre><code>CustomerDataGrid.DataContext = tempCustomerobj; </code></pre> <p>Doing that will not in any way affect the original Customer object that is still in your <em>ObservableCollection</em>.</p> <p>To solve, don't create a <em>new</em> Customer, but rather edit an existing one.</p> <p><strong>Update</strong> </p> <p><em>Based on your comments</em></p> <p>The line</p> <pre><code>customerobj = c; //Original object </code></pre> <p>causes <code>customerobj</code> to be an alias to <code>c</code>, your object that is actually in the <code>ObservableCollection</code>.</p> <p>The line </p> <pre><code>customerobj = tempCustomerobj; </code></pre> <p>causes <code>customerobj</code> to now be an alias to <code>tempCustomerobj</code>, which is your brand-new Customer object that is (I presume) a <em>clone</em> of <code>c</code>.</p> <p>Change your constructor to </p> <pre><code>public EditCustomerWindow(Customer c) { InitializeComponent(); CustomerDataGrid.DataContext = c; } </code></pre> <p><strong>Update 2</strong></p> <p>The object you're editing should support IEditableObject. See </p> <p><a href="https://stackoverflow.com/a/1091240/141172">https://stackoverflow.com/a/1091240/141172</a></p> <p>Alternatively, you can serialize the object before you start editing and deserialize the saved state if the edit is canceled.</p>
 

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