julien-100000 julien-100000 - 1 year ago 96
Vb.net Question

How to cut off overlapping areas?

My problem is that I want to create my own custom Control. In this control there is only a rectangle. This rectangle can be rotated. When i e.g. rotate the rectangle for 45 degrees then the rectangle overlaps. But i want that the overlappinmg areas are cut off.

This is what it looks like now:

This is what i want it to look like:

enter image description here

Is there any way to do this with WPF?

Answer Source

You have to, either programmatically or via XAML, set the control's ClipToBounds property to True.

Via code in the constructor:

Public Sub New() 'VB.NET
    Me.ClipToBounds = True
End Sub
public yourControl() { //C#
    this.ClipToBounds = true;


<yourControl ClipToBounds="True" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download