Telerik RadComboBox 不显示所选项目
我有一个 RadComboBox,如下所示,
<telerik1:RadComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,2" ItemsSource="{Binding RepTypes}" DisplayMemberPath="Path=TypeName" SelectedValuePath="Value" SelectedItem="{Binding RepType, Mode=TwoWay}" >
</telerik1:RadComboBox>
当我选择一个项目时,我捕获了属性更改事件,但基本上组合框中的选择保持空白。
我做错了什么?
好吧,我做到了,所以它现在显示了..但我不明白为什么...或者如何更改它,以便它在所有情况下都适合我...
<telerik1:RadComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,2" ItemsSource="{Binding RepTypes}" SelectedValuePath="Value" SelectedItem="{Binding RepType, Mode=TwoWay}" >
</telerik1:RadComboBox>
这就是有效的...最大的区别是。我必须将一个字段命名为“Name”,然后绑定它并取出 DisplayMemberPath="Path=ReportName"
如果是这种情况,那么我如何告诉控件在下拉列表中显示哪个字段?
I have a RadComboBox that i have bound like shown below
<telerik1:RadComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,2" ItemsSource="{Binding RepTypes}" DisplayMemberPath="Path=TypeName" SelectedValuePath="Value" SelectedItem="{Binding RepType, Mode=TwoWay}" >
</telerik1:RadComboBox>
When i select an Item I catch the Property Changed event, but basically the selection in the combo box stays blank.
What am i doing wrong?
Ok i made it so that it shows up now.. But i don't understand why... Or how to change it so it works for me in all cases...
<telerik1:RadComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,2" ItemsSource="{Binding RepTypes}" SelectedValuePath="Value" SelectedItem="{Binding RepType, Mode=TwoWay}" >
</telerik1:RadComboBox>
Thats what works... the Biggest difference was. I had to name a field to "Name" and then bind it and take out the DisplayMemberPath="Path=ReportName"
If that is the case then how do i tell the control what Field to Display in the dropdown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在以某种方式改变您的收藏?控件仅查找项目一次。因此,如果页面加载,然后您加载 RepType 集合,它不会更新字典。我正在做类似的事情,并且我正在延迟加载我的集合(当您键入时,我从数据库中获取更多信息)。
Are you somehow changing your collection? The controls only look for the items once. So, if the page loads and then you're loading your collection of RepTypes, it doesn't update the dictionary. I'm doing something similar and I'm lazy loading my collection (as you type, I get more from the database).
如果您希望
ReportName
显示为您的显示成员,您只需这样表述:您放置一个额外的“Path=”,这只会使 XAML 解析器感到困惑。
If you want
ReportName
to be shown as your display member, you only have to put it this way:You're putting an extra "Path=" that's only confusing the XAML parser.