If you follow MVVM to the letter, you would end up with an additional property in your VM. So you'd have Data
for the binding source, SelectedItem
for the current selected item, and ModifiedItem
for the value in the textbox. Then in your XAML, each of your controls would only be bound to the VM, rather than being bound to each other in any way. (I usually find that when controls are bound to one another, that means the VM is a little underdeveloped. Of course, sometimes simplicity wins out over architectural purism.)
<Window ...>
...
<StackPanel>
<TextBox Name="textBox" Text="{Binding ModifiedItem}" />
<ListBox Name="listBox" ItemsSource="{Binding Data}" SelectedItem="{Binding SelectedItem}" />
</StackPanel>
</Window>
Note that it would be up to the VM to set ModifiedItem
when the SelectedItem
property changes. Then the TextBox
will write back to that same property due to the two-way binding on the Text
property.