I have a View that contains a Combobox
. The Combobox
SelectedItem
property is data bound to SelectedX
property of View Model as two way data binding. When the viewModel is initialized, the SelectedX
property is set correctly. But after that when the view renders, it resets the value of SelectedX
(since the binding is two-way).
So the two way data binding for the Combobox
is basically not working. Please advise.
This is the xaml for my view. I initialize the View model first with apprpriate values for Relationships and SelectedX. When the view renders, the combo box resets the value for SelectedX. (I figured that by adding breakpoints). Hope this helps
<ComboBox Grid.Row="1" Grid.Column="1" Margin="5" Background="White" BorderBrush="DarkGray"
SelectedItem="{Binding SelectedX, Mode=TwoWay}"
ItemsSource="{Binding Relationships}" DisplayMemberPath="Value"
SelectedValuePath="Value" SelectedValue="{Binding Key, Mode=TwoWay}"
IsEditable="False" IsReadOnly="True" />