2010-09-24 92 views
2

我有我已绑定像图所示Telerik的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> 

当我选择一个项目我赶上属性更改事件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> 

那什么起作用......最大的区别是。我必须命名为“名称”字段,然后绑定它并取出DisplayMemberPath =“Path = ReportName”

如果是这种情况,那么我该如何告诉控件在下拉菜单中显示的字段?

回答

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

如果你想ReportName被显示为您的显示部件,你只需要这样说:

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

</telerik1:RadComboBox> 

你把一个额外的“路径=”那只是混淆XAML解析器。

相关问题