I have a combobox that has a list of objects called LookupValues and in that combobox I am binding to the DisplayText to my observable开发者_C百科 collection of LookupValues.
I have a listbox that is bound to an observable collection of RelationshipStatus. In this list of RelationshipStatus is a property of Relationship Types. which is what i display in my list box.
When the selected item in the listbox is chosen i want to display the information in the detail section of my view. i have all the other bindings to controls working except this combobox. below is my xaml for the combobox.
<telerik:RadComboBox Grid.Row="0"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
DisplayMemberPath="DisplayText"
ItemsSource="{Binding MainStatusList, Mode=TwoWay}"
SelectedItem="{Binding ElementName=lstRelationshipStatus, Path=SelectedItem.RelationshipValue, Mode=TwoWay}" />
my items sources is that list of lookup values, the displaymemberpath displays the DisplayText property. The selectedItem section is binding to the listbox element but the path doesnt seem to work. the Path=SelectedItem.RelationshipValue should bind to the combobox and display the correct item...im guessing that is has to do with the fact these are different types. The listbox has a RelationshipStatus type with a RelationshipValue property and the combobox has a LookupValue type with a DisplayText property..?
You can try adding ItemTemplate to this combo box so it could know what to bind. Something like:
<RadComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Content="{Binding WhereToBind}" />
</DataTemplate>
</RadComboBox.ItemTemplate>
Or add a value converter, which converts from RelationshipValue to LookupValue.
精彩评论