How to hide the Column header in a WPF DataGrid?
Asked Answered
Z

3

45

I am using a DataGrid in Expression Blend but I just need to show only the registries and hide the ColumnHeader.

How do I do that?

Zildjian answered 2/7, 2009 at 18:17 Comment(0)
N
97

In the DataGrid there is a Header section where the field Header Visibility could be set to None.

Or in xaml for the Datagrid add the property

HeadersVisibility="None"
Nacelle answered 2/7, 2009 at 19:17 Comment(0)
C
18

Both DataGrid of namespace System.Windows.Controls and WpfToolkit:DataGrid of Microsoft.Windows.Controls have the property

HeadersVisibility="None"

In the properties window of DataGrid you can indeed choose from the available options

None
Column
Row
All

But this doesn't appear in the Properties window of WpfToolkit:DataGrid So as far as I know, you need to type that in inside your .xaml file.

<WpfToolkit:DataGrid HeadersVisibility="None">
       ...
</WpfToolkit:DataGrid>

If you want I can post the whole UserControl. Is that useful ?

Corelli answered 11/5, 2011 at 12:52 Comment(0)
D
1

This may be double posted, SO is being weird, but you can do this from code behind too.

C# code behind with a XAML datagrid named dg_Main would be:

dg_Main.HeadersVisibility = Microsoft.Windows.Controls.DataGridHeadersVisibility.None;

Doing this in code behind makes it easy to dynamically show and hide headers as needed.

Dogface answered 30/7, 2009 at 15:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.