dest177
dest177
2020-09-03 16:38

WPF的Datagrid如何绑定复杂类型的对象属性

  • c#
  • asp.net
  • microsoft
  • visual studio
// dataGrid要显示的绑定类
public class Student
{
    public long id { get; set; }    // ID
    public string name {get; set;}
    public string ip { get; set; }

    public Group group;
}

public class Group
{
    public string groupName;
    public string groupIp;
}

如何让下面的XAML的DataGrid绑定的时候显示Student里面的group类型的groupName信息?

<DataGrid>
    <DataGrid.Columns  >
        <DataGridTextColumn Binding="{Binding ???}" Header="ID" />
        <DataGridTextColumn Binding="{Binding ???}" Header="学生姓名" />
        <DataGridTextColumn Binding="{Binding ???}" Header="学生IP" />
        <DataGridTextColumn Binding="{Binding ???}" Header="学生所属组名" />
        <DataGridTextColumn Binding="{Binding ???}" Header="学生所属组IP" />
        <DataGridTextColumn Width="*" />
    </DataGrid.Columns>
</DataGrid>                 
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐