Can't eliminate padding/margin between Tiles in Windows 8 Metro 'ListView'
c#, listview, padding, windows-8, xaml
Solution
You should supply a negative `Margin`:
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,-8" />
</Style>
</ListView.ItemContainerStyle>
Problem
I'm trying to build two `ListView` objects within a `StackPanel` and have all of the `ItemTemplate` Tiles "touch" each other (meaning no margin or padding within the `ListView`s). It seems that Windows 8 Metro has some sort of built-in padding/margin. My question: How do I remove these or set them to `0`? Here is my code: ``` <StackPanel x:Name="teesSP" HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Top" > <ListView x:Name="timesLV1" SelectionMode="Multiple" SelectionChanged="timesLV_Click" ItemTemplate="{StaticResource TimeTileTemplate}"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="Padding" Value="0"/> <Setter Property="Margin" Value="0"/> </Style> </ListView.ItemContainerStyle> </ListView> <ListView x:Name="timesLV2" SelectionMode="Multiple" SelectionChanged="timesLV_Click" ItemTemplate="{StaticResource TimeTileTemplate}"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="Padding" Value="0"/> <Setter Property="Margin" Value="0"/> </Style> </ListView.ItemContainerStyle> </ListView> </StackPanel> ``` My `ItemTemplate` is: ``` <DataTemplate x:Key="TimeTileTemplate"> <Grid HorizontalAlignment="Center" Background="White" > <Border BorderBrush="Black" BorderThickness="2" > <StackPanel Margin="0,0,0,0" Orientation="Horizontal" Width="130" Height="60" VerticalAlignment="Center" > <TextBlock Margin="2,0,0,0" TextWrapping="Wrap" Style="{StaticResource ItemSubtitleStyle}" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding startTime}" Width="70" /> <TextBlock TextWrapping="Wrap" Style="{StaticResource ItemTitleStyle}" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{Binding startHole}" Width="40" /> </StackPanel> </Border> </Grid> </DataTemplate> ``` ...and it renders the following: