DevExpress ComboBoxEdit - 绑定仅返回路径而不是值

时间:2015-02-18 17:28:42

标签: wpf devexpress

我有一个DevXpress ComboBoxEdit,其XML代码如下

<dxe:ComboBoxEdit Grid.Row="1" Height="26" HorizontalAlignment="Left" Margin="37,27,0,0" 
                 Name="cbExcelReports" VerticalAlignment="Top" Width="664"
                 IsTextEditable="False"
                 DisplayMember="DisplayName"
                 Style="{StaticResource ValidationStyle}" Focusable="True"
                 ItemsSource="{Binding AllExcelReports}" SelectedItem="{Binding ReportType, Mode=OneWayToSource, Path=ReportType}"
                 Grid.ColumnSpan="2">
        </dxe:ComboBoxEdit>

此绑定适用于检索要放置在下拉列表中的项目,用户可以选择一个,并在选中时显示在组合框中。

我只需要组合框中所选项目的文本,我在绑定中使用此字符串属性

 private string _ReportType;

public string ReportType
     {
         get { return this._ReportType; }
         set
         {
             this._ReportType = value;
             RaisePropertyChanged("ReportType");
         }
     }

当我在组合框中选择一个项目时,我只获得对象的路径(如果这是正确的术语?),而不是选择的实际文本。 (显示在下面的消息框中)

enter image description here

我感觉我的XML代码是错误的,但是我无法理解它是什么,doe的任何人都有一个可以推动我朝着正确方向前进的答案吗?

非常感谢

2 个答案:

答案 0 :(得分:0)

对于每个组合框项目,您必须定义使用TextSearch.Text选择此项目时显示的文本:

      <ComboBoxItem TextSearch.Text="this is text of this item">

答案 1 :(得分:0)

在这里创建答案,因为我使用了不同的方法来使用ObservableCollections。我最终使用了一个字典并将字典绑定到组合框,这很好。只有所选的值才具有任何重要性,所以现在没问题。