WPF Border Thickness increase direction
Asked Answered
A

2

10

Hey. Another WPF question. In my XAML code I have a border:

<Border x:Name="myBorder" Background="AliceBlue" 
    Width="200" Height="200" 
    BorderThickness="10" BorderBrush="Black">
</Border>

and somewhere in code I increase the BorderThickness

double thickness = myBorder.BorderThickness.Bottom + 2;
myBorder.BorderThickness = new Thickness(thickness);

and the result is that the border's weight increases but not outside the 200x200 width-height, but inner, decreasing the dimension. Is there a way to do the opposite?

Allieallied answered 12/4, 2010 at 11:8 Comment(0)
A
9

Well, actually you should set the width and height on the inner or outer control of the border, not on the border itself. Then you can set a negative margin for the border, equal to minus the value of the border thickness. Something like this should to the trick:

<Border x:Name="myBorder" Background="AliceBlue" 
Margin="-10,-10,-10,-10" BorderThickness="10" BorderBrush="Black">
    <Button Background="Red" Content="Test" Width="200" Height="200"></Button>
</Border>
Arachnoid answered 12/4, 2010 at 13:11 Comment(0)
D
0

It looks like you need to increase Width and Height accordingly.

Doerr answered 12/4, 2010 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.