WPF 中的listview 怎样绑定结构体数组?

我定义的一个结构体数组,结构体里有三个属性,怎样把这个结构体数组三个属性的数据相应的显示在一个listview 里?

//定义数据结构
class Student
{
    public int Id { get; set; }
    public string Name { get; set; }
    public DateTime Birth { get; set; }
}

//定义ListView 视图结构
<ListView x:Name="livStudent">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Path=Id}" />
            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}" />
            <GridViewColumn Header="Birth" DisplayMemberBinding="{Binding Path=Birth}" />
        </GridView>
    </ListView.View>
</ListView>

//构造数据源
var students = new Student[2];
students[0] = new Student() { Id = 1, Name = "a", Birth = new DateTime(2015, 1, 1) };
students[1] = new Student() { Id = 2, Name = "b", Birth = new DateTime(2015, 2, 1)};
//绑定数据
livStudent.ItemsSource = students;


DisplayMemberBinding="{Binding Path=Id}"

设置绑定的属性名称, 注意:是属性。

温馨提示:答案为网友推荐,仅供参考