我正在后端类中使用2个列表.每个列表都是不同的类型.想要向用户显示单个列表(包含两个列表的并集),当选择此列表中的项目时,将显示项目的详细信息.
代码看起来像:
我的后端课看起来像这样的事情
public ObservableCollection<Person> People {get;}
public ObservableCollection<Product> Products {get;}
Run Code Online (Sandbox Code Playgroud)
我的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>
Run Code Online (Sandbox Code Playgroud)
有什么建议?