I have a DataTemplate that displays a TextBlock (and other stuff). This template is used both for it self in one view and as a ItemTemplate for a ListView on another view.
The problem is that one TextBlock I'm using has some kind of top-margin (or padding) when displayed in the ListView. I've tried resetting margin, padding, line-height and so on with no success.
So I'm looking for a solution. The best would be if it looks the same.. But another solution would be to add a style to the ListView telling that the specific TextBlock would have a minus top-margin.
The DataTemplate:
<DataTemplate x:Name="TemplateName">
<StackPanel
Background="White"
Margin="12, 12, 12, 12">
<TextBlock
FontSize="42"
Visibility="{Binding Path=..., Converter={StaticResource ...}}"
Text="{Binding ..., Converter={StaticResource ...}, Mode=OneWay}"
Foreground="{Binding ..., Converter={StaticResource ...}, Mode=OneWay}" />
... Other elements
</StackPanel>
</DataTemplate>
If possible, I would like to change the margin of the TextBlock when used in a ListBox. The following example doesn't work:
<ListView ...>
<ListView.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0, -15, 0, 0"/>
</Style>
</ListView.Resources>
</ListView>
This is used in a Windows Phone 8.1 "Store app".