I’m working on Silverlight 4, and I have difficulties to make my combobox work correctly.
On changing selected items, selectedItem value stays null. I defined combobox as following:
<ComboBox
x:Name="ProductGroupCombobox"
Grid.Row="2"
Margin="10,15"
Height="30" Width="200"
Background="{x:Null}"
BorderBrush="{x:Null}"
ItemsSource="{Binding}"
SelectionChanged="ProductGroupCombobox_SelectionChanged"
SelectedItem="{Binding Path=ProductType, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
<ComboBox.ItemTemplate>
</ComboBox>
Does anyone have idea?
Your
SelectedItemproperty needs to be bound to an instance in your collection, whereas it appears you have yourDataContextset to what I am assuming is a collection. Note how I adjusted the binding to be that of the collection and a separate property to be that of an instance within the collection.