I have a wpf application where I use a listView with a gridView set as its view. It has several columns which I've customized.
The problem is they don't fill the entire listView width, as in the image below:
Below are the styles for listview and gridview column header:
<!--
GridView column header
-->
<Style TargetType="{x:Type GridViewColumnHeader}" x:Key="style_header">
<Setter Property="FontSize" Value="11"/>
<Setter Property="Foreground" Value="#90969e"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="Height" Value="24"/>
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/images/bg_title_table_strip.png"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush">
<Setter.Value>
<ImageBrush ImageSource="/images/black_line.png"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Grid SnapsToDevicePixels="true">
<Border x:Name="HeaderBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0, 1" Background="{TemplateBinding Background}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="7"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Rectangle x:Name="UpperHighlight" Fill="Transparent" Visibility="Collapsed"/>
<Border Padding="{TemplateBinding Padding}" Grid.RowSpan="2">
<ContentPresenter x:Name="HeaderContent" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="0" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</Grid>
</Border>
<Canvas>
<Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/>
</Canvas>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{x:Null}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="{x:Null}"/>
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="20"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
ListView
-->
<Style x:Key="style_listView" TargetType="{x:Type ListView}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="1072"/>
<Setter Property="Height" Value="686"/>
<Setter Property="AlternationCount" Value="2"/>
<Setter Property="Margin" Value="10,10,11,14"/>
<!--<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>-->
</Style>
Q: What is wrong and how can it be solved?
Any help highly appreciated.