1

What am I forgetting here?

<ComboBox ItemsSource="{Binding MyList} SelectionChanged="Selector_OnSelectionChanged"/>
<TextBlock Text="{Binding SelectedItem}"/>
<MyControl DataContext="{Binding SelectedItem}" />

Changing the selectedItem updates the testBlock but does not fire DataContextChanged event in my control. It does fire the event on the first selction, but not any subsequent selections.

user1604008
  • 995
  • 9
  • 17
  • Can you provide some more information? What does your view model look like? What is the MyList object? How are you choosing what values are selected from the Combo Box, etc... – Benji Vesterby Sep 26 '13 at 16:46
  • what objects does Mylist has? strings? are they unique? – Nitin Sep 26 '13 at 16:47
  • My guess is that you must implement INotifyPropertyChanged, so that when a change happens in SelectedItem the interface "receives" that change. – sexta13 Sep 26 '13 at 17:35

1 Answers1

0

I'm going to answer my own question here for the record. I should probably ask a new question because I'm still flummoxed.

The problem I was having was because I had the following in my OnDataContextChanged handler:

DataContext = dependencyPropertyChangedEventArgs.NewValue;

Obviously this is redundant since the DataContext is already set (its been a rough week). Removing this line solves the problem. However, I'm still at a loss as to why this would cause any problems.

user1604008
  • 995
  • 9
  • 17
  • I've run into a similar problem before. See [my answer here](http://stackoverflow.com/a/5797150/) for more of an explanation. – Luke Woodward Sep 26 '13 at 19:12