编程的ListViewItem添加到列表视图中的WPF [英] Add programmatically ListViewItem to Listview in WPF

查看:534
本文介绍了编程的ListViewItem添加到列表视图中的WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
   WPF的ListView - 如何以编程方式添加项目

如何能在C#做什么?

推荐答案

这是你将如何添加 ListViewItem的在code创建你的的ListView

This is how you would add a ListViewItem created in code to your ListView:

myListView.Items.Add(new ListViewItem { Content = "This is an item added programmatically." });

不过,我同意 MrTelly ,这不应该是必要的,您应该设置 ListView.ItemsSource 来一些集合,而不是操纵 ListView.Items 直接

However, I agree with MrTelly that this shouldn't be necessary, you should be setting ListView.ItemsSource to some collection rather than manipulating ListView.Items directly.

如果您给我们介绍一下你要完成的,也许我们可以帮什么更多的细节,你做的WPF方式,这并不总是在第一次简单的方法,但它的中长多的容易运行。

If you give us more details about what you want to accomplish maybe we can help you do it the WPF way, which is not always the easy way at first, but it's much easier in the long run.

这篇关于编程的ListViewItem添加到列表视图中的WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆