Kuriyama Mirai
Kuriyama Mirai

Reputation: 937

Title for datagrid

How can I able to put a title to my datagrid in WPF . All I can do is style my column headers but putting a title for my whole table is impossible for me. Can anyone help me out. Here's the image of the table I want to have.

enter image description here

Upvotes: 3

Views: 6731

Answers (2)

sporeing
sporeing

Reputation: 33

You can add another control (i.e. Label, TextBlock) before the DataGrid to contain your title.

I usually use a StackPanel for these things:

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

Upvotes: 1

pushpraj
pushpraj

Reputation: 13669

here is a sample

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

above example use a DockPanel as the main container and a TextBlock on the top as the heading and DataGrid in rest of the area.

I give a sample style, you may style the header as desired

Upvotes: 8

Related Questions