【发布时间】:2021-02-26 15:32:24
【问题描述】:
我有一个显示信息列表的ComboBox:
NameOfEstablishmentBINOwnerBusinessAddress
...看起来像这样:
代码:
<ComboBox x:Name="BploList"
Text="{Binding Search}"
SelectedItem="{Binding SearchSelected}"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
FontSize="16"
materialDesign:HintAssist.Hint="Search"
Margin="5 5 65 5"
IsEditable="True">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding NameOfEstablishment}" FontSize="12" Foreground="#D8AC6A"
TextWrapping="Wrap" MaxWidth="250" />
<TextBlock Text="{Binding BIN}" FontSize="11" TextWrapping="Wrap" MaxWidth="250" />
<TextBlock Text="{Binding Owner}" FontSize="11" TextWrapping="Wrap" MaxWidth="250" />
<TextBlock Text="{Binding BusinessAddress}" FontSize="11" TextWrapping="Wrap" MaxWidth="250" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
问题
SelectedItem 应该显示NameOfEstablishment 值仅,但它却显示为完整对象:
关于ComboBox的来源
private BindingList<BPLOSearchModel> _bploList;
public BindingList<BPLOSearchModel> BploList
{
get { return _bploList; }
set
{
_bploList = value;
NotifyOfPropertyChange(() => BploList);
}
}
BPLOSearchModel 的属性
public class BPLOSearchModel
{
public string BIN { get; set; }
public string NameOfEstablishment { get; set; }
public string BusinessAddress { get; set; }
public string Owner { get; set; }
}
至于 SearchSelected
private string _searchSelected;
public string SearchSelected
{
get { return _searchSelected; }
set
{
_searchSelected = value;
NotifyOfPropertyChange(() => SearchSelected);
}
}
【问题讨论】:
-
@MickyD 好的,已编辑。
-
感谢您的编辑
标签: c# wpf xaml caliburn.micro