WPF: Spilt GridView header into two rows where the bottom row is seperated into two colums

I´m trying to separate a gridViewColumn into two rows. Im using default style for the listView. Its no problem to separate the column header into two rows, but it seems like the content is placed over the original style with the border etc hidden under my customized gridViewHeader content. The code looks like:

<GridViewColumnHeader>
    <GridViewColumnHeader.Template>
        <ControlTemplate>
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
                <Grid ShowGridLines="False" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Text="SomeHeaderText" HorizontalAlignment="Center"/>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="SubHeaderText1" Padding="5"  HorizontalAlignment="Center" />
                            <TextBlock Grid.Column="1" Text="SubHeaderText1" Padding="5" HorizontalAlignment="Center" />                                                
                        </Grid>
                    </Grid>
            </Grid>
        </ControlTemplate>
    </GridViewColumnHeader.Template>
</GridViewColumnHeader>

Anyone knows how to cutomized the GridViewHeader like this example and keep the appearance of the GridViewHeader

Answers


You should put your customized template just as a content of the GridViewColumnHeader, not as its template. Here is the correct XAML:

<GridViewColumnHeader>
   <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
      <Grid HorizontalAlignment="Center" VerticalAlignment="Center" ShowGridLines="False">
         <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
         <TextBlock Grid.Row="0" HorizontalAlignment="Center" Text="SomeHeaderText"/>
         <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="*"/>
               <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock
               Grid.Column="0"
               HorizontalAlignment="Center"
               Padding="5"
               Text="SubHeaderText1"/>
            <TextBlock
               Grid.Column="1"
               HorizontalAlignment="Center"
               Padding="5"
               Text="SubHeaderText1"/>
         </Grid>
      </Grid>
   </Grid>
</GridViewColumnHeader>

Need Your Help

How to transform a WebService call that is using behaviours?

c# javascript web-services asp.net-1.1 behavior

We have some really old code that calls WebServices using behaviours (webservice.htc), and we are having some strange problems... since they've been deprecated a long time ago, I want to change the...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.