在 .NET Core 3.1 的 WPF 程序中打算用 ListBox 绑定显示一个集合(满足需求即可,无所谓什么类型的集合),以下是 Xaml 代码(瞟一眼就行,不是本文讨论重点):
<ListBox ItemsSource="{Binding SipRegistrations, Mode=OneWay}" SelectedValue="{Binding SelectedAccountBinding, Mode=OneWayToSource}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding SIPAccount.SIPUsername}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
… 阅读全文