views:

2462

answers:

2

Hello, 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

+1  A: 

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>
ligaz
A: 

Hello, can I do this dynamicly, too??? I don't know the columns which I need at implementation time. So I have build dynamicly... How can I do this??? Thx for help...

Elm...
You won't get an answer this way. Start a new question and link back to this one for reference.
Aaronaught