Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
信不信由你,我在谷歌上搜索过,但我找不到如何查看列表视图是否为空。如果是这样,我想隐藏一些控件。我试过 lv.items.count 但它总是返回 0。无论控件是否为空。
lv.Items.Count仅当您在绑定数据之前检查时才会返回 0 。如果在绑定数据后检查,它会返回行数。
lv.Items.Count
Icarus 关于绑定的顺序是正确的,但我想指出这lv.Items.Any()是查看是否有要显示的任何项目的更有效方法。如果您只想知道其中是否至少有一件东西,那么计算整个列表是没有意义的。
lv.Items.Any()