我正在与后端类中的两个列表一起工作。每个列表都是不同类型的。希望向用户呈现单个列表(包含两个列表的并集),当选择此列表中的项目时,该项目的详细信息将出现。
代码将类似于:
我的后端类大致如下
public ObservableCollection<Person> People {get;}
public ObservableCollection<Product> Products {get;}
我的XAML大致长这个样子
<ListBox x:Name="TheListBox" ItemsSource={Some Expression to merge People and Products}>
<ListBox.Resources>
People and Product Data Templates
</ListBox.Resources>
</ListBox>
...
<ContentControl Content={Binding ElementName=TheListBox, Path=SelectedItem }>
<ContentControl.Resources>
Data Templates for showing People and Product details
</ContentControl.Resources>
</ContentControl>
有什么建议吗?