How to add a column in a Listview dynamically using WPF

来源:百度文库 编辑:神马文学网 时间:2024/04/28 11:33:59
Hi,
I have created a Listview with five columns, which is hard coded. I alos want to create a column in a Listview using WPF in runtime. i.e when a "Add Column" button is added a new column must be added with the Listview dynamically in runtime. As am new to WPF application I need coding help in this issue.
Thankfully,
Cbe
Cbe
you can get the GridView by accessing the view property of the listview and then add columns
GridView myGridView = listview1.View;
GridViewColumn gvc1 = new GridViewColumn();
gvc1.DisplayMemberBinding = new Binding("FirstName");
gvc1.Header = "FirstName";
gvc1.Width = 100;
myGridView.Columns.Add(gvc1);
lee d
Hi,
Thank you dude.. Its working but the value is not binded...
Thankfully,
Cbe
Cbe
Do you see any binding errors in the output window? Can you share the code?