ListView显示System.Data.DataRowView而不是DataTable
本文关键字:DataTable DataRowView 显示 System Data ListView | 更新日期: 2023-09-27 17:51:14
我的问题是,每一行的ListView显示"System.Data "。DataRowView"在我用一个样式改变ListView模板后。
我已经在这里定义了数据表:
DataTable data = new DataTable();
lsvOutput.ItemsSource = data.DefaultView;
这是列的XAML:
<ListView.View>
<GridView>
<GridViewColumn Header="column1" DisplayMemberBinding="{Binding column1}"/>
<GridViewColumn Header="column2" DisplayMemberBinding="{Binding column2}"/>
<GridViewColumn Header="column3" DisplayMemberBinding="{Binding column3}"/>
</GridView>
</ListView.View>
我假设这是它断裂的部分:
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
我明白了。我替换了这个:
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
与这个:<GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
来源:http://msdn.microsoft.com/en-us/library/ms788747%28v=vs.110%29.aspx