Note that there are some explanatory texts on larger screens.

plurals
  1. POBorderThickness of 1 renders with a 2-pixel thickness - what am I missing here?
    text
    copied!<p>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?</p> <p>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):</p> <pre><code>&lt;ControlTemplate x:Key="HeaderTemplate" TargetType="{x:Type Label}"&gt; &lt;Border BorderThickness="0,0,0,1" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Margin}"&gt; &lt;Border.BorderBrush&gt; &lt;LinearGradientBrush StartPoint="0,0" EndPoint="1,0"&gt; &lt;GradientStop Offset="0" Color="Black"/&gt; &lt;GradientStop Offset="0.6" Color="Black"/&gt; &lt;GradientStop Offset="1" Color="Transparent"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.BorderBrush&gt; &lt;TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" Style="{StaticResource HeaderStyle}" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding}"/&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; </code></pre> <p>I'm pretty new to WPF, so I suspect I'm missing something fundamental about its rendering model.</p> <ul> <li>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.</li> <li>Is there a way to guarantee that I get what I'm asking for in terms of thickness?</li> <li>Have I even made a howling error?</li> </ul> <p>And for reference, I'm not applying a scaling transform (or any other sort of transform for that matter). Any help would be appreciated. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload