WPF下DataGrid的不显示头部的问题

woshinia 2012-10-19 02:12:31
<DataGrid Name="lstSalary" FontSize="15" Grid.Row="1" Grid.Column="1"
AutoGenerateColumns="False" ItemsSource="{Binding}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" CanUserSort="True" />
<DataGridTextColumn Header="Age" Binding="{Binding Age}" CanUserSort="True" />
</DataGrid.Columns>
</DataGrid>

结果我显示的是
Tom 10
Mary 11
John 12
Clark 10
但我看微软的示例上,应该要显示
Name Age
Tom 10
Mary 11
John 12
Clark 10
才对。

为什么头部的Name和Age没有显示出来呢,求解释,.Net新手,请务必详细说明
...全文
505 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
woshinia 2012-10-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

XML code

<Window x:Class="GroupBox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title……
[/Quote]

正常情况是能显示的,但是我想问一下,什么情况下会出现头消失呢?环境问题,还是什么设置能造成呢?
q107770540 2012-10-19
  • 打赏
  • 举报
回复

<Window x:Class="GroupBox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid Name="lstSalary" FontSize="15" Grid.Row="1" Grid.Column="1"
AutoGenerateColumns="False" ItemsSource="{Binding}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" CanUserSort="True" />
<DataGridTextColumn Header="Age" Binding="{Binding Age}" CanUserSort="True" />
</DataGrid.Columns>
</DataGrid>


</Grid>
</Window>



试了,可以显示出来

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧