多列ListView WPF

时间:2015-06-01 19:14:57

标签: c# wpf xaml listview

我是WPF新手,我有ListBoxListView。当在ListBox中选择一个项目时,我需要填充ListView(它可能有单列或多列),但所有这些都在运行时决定。

<ListBox 
    Name="lstSelect" 
    Grid.Column="0" 
    Grid.Row="1" 
    Margin="0,0,5,10" 
    SelectionChanged="lstSelect_SelectionChanged"/>

<ListView 
    Name="lstValue" 
    Grid.Column="1" 
    Grid.Row="1" 
    Margin="0,0,0,10"/>

GridViewColumn gvCode = new GridViewColumn();
                    gvCode.Header = "Period Number";
                    gvCode.DisplayMemberBinding = new Binding("PERIOD_NUMBER");
                    gvValue.Columns.Add(gvCode);

                    GridViewColumn gvDesc = new GridViewColumn();
                    gvDesc.Header = "Description";
                    gvDesc.DisplayMemberBinding = new Binding("DESCRIPTION");;
                    gvValue.Columns.Add(gvDesc);
                    lstValue.ItemsSource = dt.DefaultView;    
lstValue.ItemsSource = list; 

但它没有正确显示值,只是说System.Data.DataRow

0 个答案:

没有答案