2

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

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

4

2 回答 2

4

你是否以某种方式改变你的收藏?控件只查找项目一次。因此,如果页面加载,然后您正在加载您的 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>
于 2010-12-27T15:55:09.703 回答
0

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

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

</telerik1:RadComboBox>

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

于 2011-09-27T14:30:08.810 回答