且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何WPF TreeView控件绑定到一个List<饮料>编程?

更新时间:2022-05-20 02:57:21

您可以只设置:

treeView1.ItemsSource = coldDrinks;

不过,我怀疑这里使用一个TreeView的。你显然呈现出平整,无分层数据,因此没有理由用一个TreeView。

However, I question the use of a TreeView here. You're obviously showing flat, non-hierarchical data, so there is no reason to use a TreeView.

为什么不直接使用一个ListView或列表框?

Why not just use a ListView or ListBox?