There is a tiny margin on the left side in the style when using the grouping functionality of the ListView in WPF.
Sample of ListView with grouping problem (margin):
Sample of ListView without grouping (want same style of item in grouped list):
Question:
How to remove the margin/padding? The (selected) item in the grouped list should fill the same space as in the ungrouped list.
Update:
<ListView Margin="20,0,0,0" ItemsSource="{Binding ItemsView}" SelectedItem="{Binding SelectedItem}" IsSynchronizedWithCurrentItem="True" SelectionMode="Single" BorderThickness="0" Background="Transparent">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate DataType="data:Item">
<DockPanel HorizontalAlignment="Stretch">
<TextBlock Text="{Binding Name}" FontWeight="Bold" Margin="0,5,5,5" />
<Separator />
</DockPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate DataType="data:Item">
<TextBlock Margin="10,10,10,10" Text="{Binding Name}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Style
for theItemsControl.GroupStyle
Property. – SheridanPadding
... the best way to find out is to colour theBackground
of the various internal controls differently. That way, you'll be able to see which control is taking up the space and act accordingly. – Sheridan