从列表框到组合框的 Silverlight 元素绑定
我有一个组合框,其中包含名为 LookupValues 的对象列表,在该组合框中,我将 DisplayText 绑定到我可观察的 LookupValues 集合。
我有一个列表框,它绑定到可观察的RelationshipStatus 集合。在此关系状态列表中,关系状态是关系类型的属性。这就是我在列表框中显示的内容。
当选择列表框中的所选项目时,我想在视图的详细信息部分显示信息。除了这个组合框之外,我拥有所有其他控件的绑定。下面是我的组合框的 xaml。
<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}" />
我的项目源是查找值列表,displaymemberpath 显示 DisplayText 属性。 selectedItem 部分绑定到列表框元素,但路径似乎不起作用。 Path=SelectedItem.RelationshipValue 应该绑定到组合框并显示正确的项目...我猜测这与这些是不同类型的事实有关。列表框有一个带有RelationshipValue属性的RelationshipStatus类型,而组合框有一个带有DisplayText属性的LookupValue类型..?
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 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..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试将 ItemTemplate 添加到此组合框,以便它知道要绑定什么。例如:
或者添加一个值转换器,将RelationshipValue 转换为LookupValue。
You can try adding ItemTemplate to this combo box so it could know what to bind. Something like:
Or add a value converter, which converts from RelationshipValue to LookupValue.