I've got a Border in XAML/WPF that I'm using to give a full-paragraph-width underline to text headings in a dialog. I set its BorderThickness property to "0,0,0,1". In some places, it ends up being rendered with a 2-pixel thick underline while in others it appears correctly as a single-pixel underline. What am I doing wrong?
Here's the control template I'm using to replace my label's visual tree (the use of a template is inconsequential, I would've thought):
<ControlTemplate x:Key="HeaderTemplate" TargetType="{x:Type Label}">
<Border BorderThickness="0,0,0,1" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Margin}">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" Color="Black"/>
<GradientStop Offset="0.6" Color="Black"/>
<GradientStop Offset="1" Color="Transparent"/>
</LinearGradientBrush>
</Border.BorderBrush>
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" Style="{StaticResource HeaderStyle}"
Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding}"/>
</Border>
</ControlTemplate>
I'm pretty new to WPF, so I suspect I'm missing something fundamental about its rendering model.
- Is the border rendering over a pixel boundary? Doesn't seem that way, as I would've thought it would be partially transparent if so.
- Is there a way to guarantee that I get what I'm asking for in terms of thickness?
- Have I even made a howling error?
And for reference, I'm not applying a scaling transform (or any other sort of transform for that matter). Any help would be appreciated. :)