How Do I Hide wpf datagrid row selector

I'm using the WPF DataGrid control to show some details and a select button, and I don't need the gray selector column down the left-hand side. It's also ruining the beauty of my design.

Is there a way to remove it, or how can I style it to match if not?

62138 次浏览

使用 RowHeaderWidth属性:

<my:DataGrid RowHeaderWidth="0" AutoGenerateColumns="False" Name="dataGrid1" />

注意,你也可以为它指定一个样式或模板,如果你决定你真的喜欢它,并希望保留它,因为你可以做一些很酷的事情。

也有同样的问题。

Looks like the RowHeaderWidth is not supported in XAML BUT you can specify in the code behind right after the bind and it takes out that crappy selector column.

GrdName. RowHeaderWidth = 0

不需要设置 Width,您可以通过设置 DataGrid 来完全隐藏行标题

HeadersVisibility="Column"

删除 wPF 中 Datagrid 的行标题(灰色字段)

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="Column">
</DataGrid>

To remove or hide the Column Header in DataGrid WPF

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="Row">
</DataGrid>

在 DataGridWPF 中移除或隐藏列标头和行标头

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="None">
</DataGrid>