views:

34

answers:

1

Here's my code:

<ComboBox Grid.Column="1" Grid.Row="9" ItemsSource="{Binding Path=PriorityEntries}" SelectedItem="{Binding Path=Priority,Mode=TwoWay}"/>

The comboBox is bound properly with PriorityEntries, and when i change the value of the comboBox the "set" of the bound property(Priority) is called setting it to what it needs to be. However, when i close the UserControl that this combobox resides, it calls the set property again with a value of null and then sets what the selectedItem was to null. Why is the comboBox being bound again when I close the usercontrol. I tried setting the mode to OneTime, but that won't reflect any changes...

A: 

You can try 'capturing' the Priority value in a property in your ViewModel before the control closes and use the captured value. You could also modify the setter for Priority so that it doesn't allow it to be set once the control associated with the ViewModel has been closed.

Dan Bryant