开发者

WPF - Clipping ContentControl inside Canvas

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 wh开发者_StackOverflowen 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜