Custom Row and Header Height of Datagrid in WPF

Introduction

In this article we will see how we can customize the row height and header height in datagrid in WPF.

Creating WPF Application

Fire up Visual Studio 2010 and create a WPF Application, name the solution as CustomDatagrid.

image1.gif

Add a Datagrid to the application by dragging from the toolbox to the designer.

image2.gif

Here are the initial settings when you add the Datagrid.

image3.gif

Now let's fill in the datagrid with sample data.

image4.gif

Now let's see how it looks without the Height customization.

image5.gif

Now, in the datagrid properties. Change the ColumnHeaderHeight to your required height in this case let's take 30.

image6.gif

As well as the RowHeight to 24.

image6.1.gif


Now run the application to see the changes.

image7.gif

That's it.

Hope this article helps.