views:

513

answers:

2

I am looking for a way to expose a property in my ViewModel and have it influenced by two separate controls in my View.

In code view, I am trying to do something like this:

propdp object MyObject...

<MySelector SelectedItem="{Binding MyObject, Mode=TwoWay}" />
<MyEditor DataContext="{Binding MyObject, Mode=TwoWay}" />

The purpose of this is to let the user select an item and edit it on the same user control, but its not working for me. When a selection is made in MySelector, the change fails to propagate to MyEditor.

Is this possible to do?

+1  A: 
<MySelector x:Name="mSelector" SelectedItem="{Binding MyObject, Mode=TwoWay}" />
<MyEditor DataContext="{Binding ElementName= mSelector,Path=mSelector}" />

Check whether that solve your problem

Jobi Joy
+2  A: 

If what you want to accomplish is have the Editor control point to what the Selector control is pointing to, simply adjust the MyEditor binding to the following:

<MyEditor DataContext="{Binding Path=SelectedItem, ElementName=mySelector}" />
sixlettervariables
+1 You have no idea how many hours I've just spent trying to work that one out! :( -> :)
chibacity