Telerik RadComboBox 不显示所选项目

发布于 2024-09-25 07:07:11 字数 868 浏览 7 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迟到的我 2024-10-02 07:07:11

您是否正在以某种方式改变您的收藏?控件仅查找项目一次。因此,如果页面加载,然后您加载 RepType 集合,它不会更新字典。我正在做类似的事情,并且我正在延迟加载我的集合(当您键入时,我从数据库中获取更多信息)。

       <t:RadComboBox x:Name="RepTypeComboBox" Margin="0,1"
                   t:TextSearch.TextPath="TypeName"
                   ItemsSource="{Binding Path=RepTypes, Mode=OneWay}"
                   SelectedValue="{Binding Path=Reptype, Mode=TwoWay, NotifyOnValidationError=True}"                            
                   IsEditable="True" 
                   Grid.Column="1"
                   Grid.Row="2" TabIndex="1">
            <t:RadComboBox.ItemTemplate >
                <DataTemplate >
                  <StackPanel Orientation="Horizontal" >
                    <TextBlock FontWeight="Bold" Text="{Binding Path=TypeName, Mode=OneWay}" Width="75"/>
                        <TextBlock Text=": " />
                    <TextBlock Text="{Binding Path=address1, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=address2, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=citystate, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=zip, Mode=OneWay}" />
                    </StackPanel>
                </DataTemplate>
            </t:RadComboBox.ItemTemplate>
        </t:RadComboBox>

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).

       <t:RadComboBox x:Name="RepTypeComboBox" Margin="0,1"
                   t:TextSearch.TextPath="TypeName"
                   ItemsSource="{Binding Path=RepTypes, Mode=OneWay}"
                   SelectedValue="{Binding Path=Reptype, Mode=TwoWay, NotifyOnValidationError=True}"                            
                   IsEditable="True" 
                   Grid.Column="1"
                   Grid.Row="2" TabIndex="1">
            <t:RadComboBox.ItemTemplate >
                <DataTemplate >
                  <StackPanel Orientation="Horizontal" >
                    <TextBlock FontWeight="Bold" Text="{Binding Path=TypeName, Mode=OneWay}" Width="75"/>
                        <TextBlock Text=": " />
                    <TextBlock Text="{Binding Path=address1, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=address2, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=citystate, Mode=OneWay}" />
                        <TextBlock Text=" " />
                    <TextBlock Text="{Binding Path=zip, Mode=OneWay}" />
                    </StackPanel>
                </DataTemplate>
            </t:RadComboBox.ItemTemplate>
        </t:RadComboBox>
趁微风不噪 2024-10-02 07:07:11

如果您希望 ReportName 显示为您的显示成员,您只需这样表述:

<telerik1:RadComboBox ItemsSource="{Binding RepTypes}" SelectedValuePath="Value"
SelectedItem="{Binding RepType, Mode=TwoWay}" DisplayMemberPath="ReportName">

</telerik1:RadComboBox>

您放置一个额外的“Path=”,这只会使 XAML 解析器感到困惑。

If you want ReportName to be shown as your display member, you only have to put it this way:

<telerik1:RadComboBox ItemsSource="{Binding RepTypes}" SelectedValuePath="Value"
SelectedItem="{Binding RepType, Mode=TwoWay}" DisplayMemberPath="ReportName">

</telerik1:RadComboBox>

You're putting an extra "Path=" that's only confusing the XAML parser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文