Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF
I have a custom control that I am making. When I add a border around the control the border goes outside the bounds of the control on the right and bottom side. I thought I once knew a way to prevent the border from doing this, but I no longer remember. Any ideas?
Posted 24-Nov-12 14:49pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It turns out that the stroke that is drawn by a control actually adds on to the size of the control. So in order to keep my control appear at a constant size no matter what the stroke thickness is, I did the following:
 
I translated the rendered portion of my control down and to the right by half the stroke thickness.
I decreased both the height and width by the stroke thickness.
 
So far this seems to have solved my problem!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 220
2 DamithSL 190
3 Raul Iloc 185
4 Richard MacCutchan 175
0 OriginalGriff 5,130
1 DamithSL 4,197
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100