I have a Border in XAML / WPF that I use to underline the full paragraph for text headings in a dialog box. I set the BorderThickness property to "0,0,0,1". In some places, it ends with a 2-pixel underline, while in others it looks right like a single-pixel underline. What am I doing wrong?
Here is the control template that I use to replace the visual tree of my label (using the template is not essential, I would think):
<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 new to WPF, so I suspect I'm missing something fundamental in his rendering model.
- Is displaying pixel border borders? Not like this, as I would have thought it would be partially transparent, if so.
- Is there a way to ensure that I get what I ask for in terms of thickness?
- Am I even mistaken howling?
And for reference, I do not use a scaling transformation (or any other transformation, for that matter). Any help would be greatly appreciated. :)
wpf xaml rendering
Mal ross
source share