Datagrid header

How can I put a header in my datagrid in WPF. All I can do is style the column headings, but putting a heading for my entire table is not possible for me. Can someone help me. Here is an image of the table I want to have.

enter image description here

+3


source to share


2 answers


here is an example

<DockPanel LastChildFill="True">
    <TextBlock Text="Details per Check Type"
               Background="Red"
               Foreground="White"
               FontSize="20"
               FontWeight="SemiBold"
               TextAlignment="Center"
               DockPanel.Dock="Top" />
    <DataGrid />
</DockPanel>

      



The above example uses the DockPanel as the main container and the TextBlock on top as the title and DataGrid in the rest of the area.

I give a style example, you can style the heading if you like

+3


source


You can add one more control (i.e. Label, TextBlock) before the DataGrid contains your title.

I usually use StackPanel for these things:



<StackPanel>
    <Label Content="Your Title goes here"/>
    <DataGrid>
        ...
    </DataGrid>
</StackPanel>

      

0


source







All Articles