Share via


Clipping of child elements

On the forums I saw this interesting problem where there was a need to round the corners of a stackpanel inside a border with cornerradius set...

The top is what you get and the bottom image is what you want. The simplest thing to do here is to set the padding on the border so that the stackpanel doesnt bleed around the corners.

But when that doesnt meet your requirements you will need to set the clip property on the child in the OnRender function so that you get the correct clipping. The code for the above is attached.(thanks to Ifeanyi)

 

Share this post

 

clippingborder.zip

Comments

  • Anonymous
    April 07, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    April 07, 2008
    The comment has been removed

  • Anonymous
    April 08, 2008
    The comment has been removed

  • Anonymous
    April 10, 2008
    Seems that the better solution will be to override GetLayoutClip method and return the geometry, used to clip the content. That could solve some potentioal problems with transformations, and also it will elliminate the problems with the Clip property itself (you wrote that you could not be animated in this case).