Click here to Skip to main content
11,496,146 members (623 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
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

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 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 25 Nov 2012
Copyright © CodeProject, 1999-2015
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