我有一个我想在DataGrid中显示的对象列表。
int LocationId { get; set; }
string LocationName { get; set; }
ProductionArea Area { get; set; }
DateTime CreateDateTime { get; set; }
string DropFolderPath { get; set; }
string CreateBy { get; set; }
int Plant { get; set; }
但我还需要一些额外的字段来显示每行的复选框,以检查是否需要操作。但也喜欢不显示所有字段,例如“LocationId”。
答案 0 :(得分:1)
您必须在DataGrid上设置AutoGenerateColumns=false
并为您的数据创建列。您可以创建任意数量的列并绑定到您要显示的唯一数据
<DataGrid AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridCheckBoxColumn/>
<DataGridTextColumn Binding="{Binding LocationName}"/>
</DataGrid.Columns>
</DataGrid>
为了在列中显示ProgressBar,您可以使用DataGridTemplateColumn并为其定义CellTemplate以使其具有ProgressBar。