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 TODO
object, which causes the RIA data context to add it to the DataContext.TODOs
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.
Here's how it works :
I've got my TODO
entity which is associated with a Status
(RIA services entity relationship).
I create a new TODO()
entity which is passed to a ChildWindow
popup. Notice that I don't add this new entity to my datacontext.
new CreateTODOPopup(new TODO()).Show();
In the DataForm in my ChildWindow I have a combobox for Status
which is databound to DataContext.Statuses
.
The problem is that the action of selecting a Status
from the dropdown actually associates the entity to the context for me - ending up giving it a state of EntityState.New
and actually adding it to the DataContext.TODOs
colleciton.
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.
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.