Hi Guys, hope you might be able to help with a problem I'm having... A summary is below:
User Control 1 displays data from a parent entity. Its ViewModel exposes an ID property that identifies an instance of a child entity. There is a 1-to-1 relationship from parent to child.
User control 2 displays data from the child entity. An instance of the user control exists within user control 1, declared in XAML. It has a dependency property that is bound to the ID field of the parent. User control 2 operates like a black-box, taking care of instantiating its own ViewModel when the ID dependency property value is set. UC2 is re-used in lots of places so I don't want to create a dependency on UC1's viewmodel to hold UC2's ViewModel.
The problem I have is that when instantiating UC1 its datacontext propogates down to UC2 before the ID Property is bound. This results in UC2 trying to update all it's bindings to the datacontext of UC1, giving a load of binding errors.
Once the ID depedncy property is set, the data-context of UC2 is updated and everything is OK - this all happens before the controls are displayed, but I want to get rid of the binding errors and prevent to dual cycle of binding.
Seems there should be a way to prevent the datacontext of a parent propogating down to child control in this kind of situation?
Thanks
Phil