There is a problem with porting the sample XAML to Silverlight, because ClipToBounds does not exist! Is there a way to simulate this function? I am happy to derive from Canvas and override the Measure / Arrange method when needed.
protected override Size ArrangeOverride(Size finalSize)
{
RectangleGeometry clipRectGeometry = new RectangleGeometry( );
clipRectGeometry.Rect = new Rect(new Point(0,0), finalSize);
Clip = clipRectGeometry;
return base.ArrangeOverride();
)
I have a Canvas in WPF, and I want to prevent its children from being drawn outside the edge of Canvas ara. In WPF, this is simple because You only need to set the ClipToBounds property on the Canvas to True, and it will execute as expected.
There is a problem with porting the sample XAML to Silverlight, because ClipToBounds does not exist! Is there a way to simulate this function? I am happy to derive from Canvas and override the Measure / Arrange method when needed.
I found the solution myself. Override the ArrangeOverride method like this…
protected override Size ArrangeOverride(Size finalSize)
{
RectangleGeometry clipRectGeometry = new RectangleGeometry();
clipRectGeometry.Rect = new Rect (new Point(0,0), finalSize);
Clip = clipRectGeometry;
return base.ArrangeOverride();
}