WPF中LISTVIEW的问题

llc961478 2013-02-08 05:23:38
现在有一个学生类 里面有Sex Age Name三个属性
设定一个ListView控件中添加几个GridViewColumn
怎么在每个GrivViewColumn中添加不同属性的值 改怎么绑定?

  List<students> stulist = new List<students>();
for (int i = 0; i < 3; i++)
{

students stu = new students();
stu.Age = i;
stu.Name = i + "haha";
stu.Sex = "男的";
stulist.Add(stu);
}


    <ListView.View>

<GridView x:Name="listgrdkecheng">


<GridViewColumn x:Name="kechengbianhao" Header="姓名" Width="200"/>
<GridViewColumn x:Name="kechengbianhao" Header="年龄" Width="200"/>
<GridViewColumn x:Name="kechengbianhao" Header="性别" Width="200"/>


...全文
513 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kation 2013-02-08
  • 打赏
  • 举报
回复
<GridViewColumn x:Name="kechengbianhao" Header="性别" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Sex}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
漏了个DataTemplate
Kation 2013-02-08
  • 打赏
  • 举报
回复
<GridViewColumn x:Name="kechengbianhao" Header="性别" Width="200">
<GridViewColumn.CellTemplate>
<Label Content="{Binding Sex}" />
</GridViewColumn.CellTemplate>
</GridViewColumn>

110,533

社区成员

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

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

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