WPF Binding Collection To ComboBox and Selecting an item
- by Adam Driscoll
I've been knocking my head against this for some time now. I'm not really sure why it isn't working. I'm still pretty new to this whole WPF business.
Here's my XAML for the combobox
<ComboBox Width="200" SelectedValuePath="Type.FullName" SelectedItem="{Binding Path=Type}" Name="cmoBox" >
</ComboBox>
Here's what populates the ComboBox (myAssembly is a class I created with a list of possible types)
cmoBox.ItemsSource = myAssembly.PossibleTypes;
I set the DataContext in a parent element of the ComboBox in the code behind like this:
groupBox.DataContext = listBox.SelectedItem;
I want the binding to select the correct "possible type" from the combo box. It doesn't select anything. I have tried SelectedValue and SelectedItem. When I changed the DisplayMemberPath of the ComboBox to a different property it changed what was displayed so I know it's not completely broken.
Any ideas???