我是WPF新手,我有ListBox
和ListView
。当在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