Question

I have a ContentControl and its content is a custom FrameworkElement. FrameworkElement has only one child and it is a DrawingVisual. Basicly the ContentControl is a container for the DrawingVisual(which contains shapes) and ContentControl has the thumbs that the user use to drag, resize, rotate the control. ContentControl is added to a Canvas to display. I want to set clipping region of the ContentControl to a specific region in the Canvas. However when I set the Clip property of ContentControl to this region(RectangleGeometry specified in Canvas coordinate system) the DrawingVisual inside the ContentControl is clipped as if the given region is in the coordinate system of the ContentControl.

I can constrain the user to drag only inside this region but i don't want to do that. I want the user to be able drag outside and when a part of ContentControl is outside I don't want that part to be rendered. How can I do this?

Was it helpful?

Solution

create an intermediate contentcontrol in the canvas, position this to be where you want things to clip, set cliptobounds=true on it, put your existing contentcontrol inside of it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top