我正在使用后端类中的 2 个列表。每个列表都是不同的类型。Would like to present the user with a single list (containing a union of both lists) of which when an item in this list is selected the item's details appear.
代码将类似于:
我的后端类看起来像这样
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>
有什么建议么?