Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent Silverlight RIA Entity getting attached to datacontext before i'm ready
    text
    copied!<p>I have a Silverlight 4 application for a simple 'TODO' list. The problem I'm having is that databinding is hooking up relationships on my <code>TODO</code> object, which causes the RIA data context to add it to the <code>DataContext.TODOs</code> list before I want it there. I want to treat the object as new and detached until I'm explicitly ready to add it to the datacontext.</p> <hr> <p>Here's how it works : I've got my <code>TODO</code> entity which is associated with a <code>Status</code> (RIA services entity relationship).</p> <p>I create a new <code>TODO()</code> entity which is passed to a <code>ChildWindow</code> popup. Notice that I don't add this new entity to my datacontext.</p> <pre><code> new CreateTODOPopup(new TODO()).Show(); </code></pre> <p>In the DataForm in my ChildWindow I have a combobox for <code>Status</code> which is databound to <code>DataContext.Statuses</code>.</p> <p>The problem is that the action of selecting a <code>Status</code> from the dropdown actually associates the entity to the context for me - ending up giving it a state of <code>EntityState.New</code> and actually adding it to the <code>DataContext.TODOs</code> colleciton. </p> <p>This would be fine except that it now appears in the main TODO list in the main frame. I don't want this becasue it hasn't been committed by the ChildWindow yet.</p> <p>How can I solve this? Either by preventing the entity from becoming attached - or by somehow hiding it from any controls it is bound to until it has been added.</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