【问题标题】:Telerik RadComboBox not showing Selected ItemTelerik RadComboBox 未显示所选项目
【发布时间】:2011-04-16 23:14:02
【问题描述】:

我有一个已绑定的 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>

当我选择一个项目时,我捕获了 Property Changed 事件,但基本上组合框中的选择保持空白。

我做错了什么?

好的,我让它现在出现了。但我不明白为什么...或者如何更改它以便在所有情况下都适用于我...

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

这就是有效的...最大的不同是。我必须将一个字段命名为“名称”,然后将其绑定并取出 DisplayMemberPath="Path=ReportName"

如果是这种情况,那么我如何告诉控件在下拉列表中显示什么字段?

【问题讨论】:

    标签: silverlight data-binding telerik radcombobox


    【解决方案1】:

    您是否正在以某种方式更改您的收藏?控件只查找项目一次。因此,如果页面加载,然后您正在加载您的 RepTypes 集合,它不会更新字典。我正在做类似的事情,我懒得加载我的收藏(当你输入时,我从数据库中得到更多)。

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

    【讨论】:

      【解决方案2】:

      如果你想让ReportName显示为你的显示成员,你只需要这样写:

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

      您添加了一个额外的“Path=”,这只会混淆 XAML 解析器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-09-30
        • 1970-01-01
        • 2021-05-02
        • 2015-04-03
        • 1970-01-01
        • 2023-03-14
        • 2013-07-17
        相关资源
        最近更新 更多