Border with real ClipToBound
When we use Border, the corner radius is not used for ClipToBound
see the solution with another border
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class ClippingBorder : Border { protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { OnApplyClip(); base.OnRenderSizeChanged(sizeInfo); } protected void OnApplyClip() { if (this.ClipToBounds) { RectangleGeometry _clipRect = new RectangleGeometry(); _clipRect.RadiusX = _clipRect.RadiusY = Math.Max(0.0, this.CornerRadius.TopLeft - (this.BorderThickness.Left * 0.5)); _clipRect.Rect = new Rect(0, 0, this.ActualWidth, this.ActualHeight); this.Clip = _clipRect; } } } |
Commentaires récents