Unable to display list items in DataGrid in WPF

后端 未结 2 1406
执笔经年
执笔经年 2021-01-27 18:53

I have created the class DisplayTable, which was mentioned below.

I have also created one list to add the contents of the class to the list.

I pushe

相关标签:
2条回答
  • 2021-01-27 19:28

    for binding, always use public properties.

    change DisplayTable.cs to

    public class DisplayTable
    {
        public int AnalyteId { get; set; }
        public int UnitCode { get; set; }
        public int ReferenceValue { get; set; }
    }
    
    0 讨论(0)
  • 2021-01-27 19:53

    DataGrid generates columns automatically only for properties, because each column creates a binding and WPF bindings require properties. DisplayTable class declares fields.

    instead of

    public int AnalyteId;
    

    make

    public int AnalyteId { get; set; }
    

    and fix other data members in the same way

    0 讨论(0)
提交回复
热议问题