DevExpress ComboBoxEdit - 仅绑定 returns 路径而不是值
DevExpress ComboBoxEdit - Binding only returns path instead of value
我有一个 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>
此绑定可以很好地检索要放置在下拉列表中的项目,用户可以 select 一个,它会在 selected 时出现在组合框中。
我只需要来自组合框的 selected 项目的文本,我在绑定中使用这个字符串 属性
private string _ReportType;
public string ReportType
{
get { return this._ReportType; }
set
{
this._ReportType = value;
RaisePropertyChanged("ReportType");
}
}
当我 select 组合框中的一个项目时,我只得到对象的路径(如果这是正确的术语?),而不是所选中的实际文本。 (显示在下面的消息框中)
我感觉我的 XML 代码是错误的,但我不能确定它是什么,有没有人有答案可以将我推向正确的方向?
非常感谢
对于每个组合框项目,您必须定义当使用 TextSearch.Text 选择该项目时显示的文本:
<ComboBoxItem TextSearch.Text="this is text of this item">
在这里创建一个答案,因为我使用了不同的方法来使用 ObservableCollections。我最终使用了字典并将字典绑定到组合框,效果很好。只有选择的值是重要的,所以现在没问题。
我有一个 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>
此绑定可以很好地检索要放置在下拉列表中的项目,用户可以 select 一个,它会在 selected 时出现在组合框中。
我只需要来自组合框的 selected 项目的文本,我在绑定中使用这个字符串 属性
private string _ReportType;
public string ReportType
{
get { return this._ReportType; }
set
{
this._ReportType = value;
RaisePropertyChanged("ReportType");
}
}
当我 select 组合框中的一个项目时,我只得到对象的路径(如果这是正确的术语?),而不是所选中的实际文本。 (显示在下面的消息框中)
我感觉我的 XML 代码是错误的,但我不能确定它是什么,有没有人有答案可以将我推向正确的方向?
非常感谢
对于每个组合框项目,您必须定义当使用 TextSearch.Text 选择该项目时显示的文本:
<ComboBoxItem TextSearch.Text="this is text of this item">
在这里创建一个答案,因为我使用了不同的方法来使用 ObservableCollections。我最终使用了字典并将字典绑定到组合框,效果很好。只有选择的值是重要的,所以现在没问题。