【发布时间】:2021-10-01 21:02:51
【问题描述】:
我有 2 张桌子,桌子 A 和桌子 B。 我想要一个列表框,其中包含两个表中的数据,如下所示:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=[field_name]}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
其中 field_name 将首先是 A.someFieldName,然后是 B.someOtherFieldName(两个名称不同!)
是否可以使用 WPF?
谢谢!
【问题讨论】:
-
从技术上讲,您可以在 ListBox 中有两列。但是使用 ListView 可能是一个更好的主意:docs.microsoft.com/en-us/dotnet/desktop/wpf/controls/…
-
要使用两个表作为数据源吗?这是不可能的。在将它们用作数据源之前,您必须先组合这些表。
-
有一个叫做MultiBinding的东西,但是解决你的问题是否是个好主意......取决于你在做什么。不确定它是否适用于列表。 stackoverflow.com/questions/2552853/…
-
@PEK 是可能的,使用复合集合。
标签: c# database wpf visual-studio listbox