Styling issue for column header in data grid in WPF

I created a Wcf Toolkit Datagrid and below is the ColumnHeader style for it But there is still some area in the column header which is not styled as shown in the picture

http://www.freeimagehosting.net/uploads/9aba4fbd93.jpg

<Style x:Key="ColumnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="Orange" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dg:DataGridColumnHeader">   
                    <dg:DataGridHeaderBorder
                    x:Name="headerBorder"                      
                    Background="Orange">
                    <Border BorderThickness="2" 
                            CornerRadius="5" 
                            Background="Orange"
                            BorderBrush="DarkOrange">                            
                        <Grid>
                            <TextBlock Text="{TemplateBinding  Content}" 
                                       VerticalAlignment="Center" 
                                       HorizontalAlignment="Center" 
                                       TextWrapping="Wrap"/>                                
                            </Grid>                                
                    </Border>
                    </dg:DataGridHeaderBorder>

                </ControlTemplate>
            </Setter.Value>
        </Setter>                 
    </Style>

 <dg:DataGrid Grid.Row="1" Grid.RowSpan="1" 
                 Name="dgQuestion"                      
                 HorizontalAlignment="Left"
                 AutoGenerateColumns="True"
                 Width="740"
                 MinWidth="200"
                 MaxWidth="740"                         
                 Background="Wheat"
                 ColumnHeaderHeight="30"                       
                 ColumnHeaderStyle="{DynamicResource ColumnHeaderStyle}"
                 RowStyle="{StaticResource RowStyle}"
                 CanUserAddRows="False"
                 CanUserDeleteRows="False"
                 AlternationCount="2"/>     

      

+1


a source to share


2 answers


Hi I just found this post with the same problem and was able to fix it for me by setting the width to the exact width of the header (where styling stops).



This may not work for you in your context. Also note that these are months :-)

+1


a source


I previously had the same problem, updating to the latest version of the grid (WPFToolkit.dll) seems to fix it for me



0


a source







All Articles