开发者

WPF Image control clipping

I have an Image control inside a custom ContentControl that I use to apply some transforms (scaling and translating through the RenderTransform). The problem is that with images bigger than the control's area, if I scroll or zoom out it's all clipped as in the original viewport.

Is there a way to force the image to draw itself completely? (already tried to set ClipToBounds to false)

By the way if I try to put an image as the background of a canvas it wor开发者_C百科ks correctly.

Edit, here's some details.

My Control:

public class CustomControl: ContentControl

The setup phase:

source = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
...
source.RenderTransform = this.transformGroup;

The transform group is made of a translation and a scale transform.

The xaml part is this:

<ui:CustomControl ClipToBounds="True">
    <Image
        Source="{Binding Path=BackgroundImage}"
        Stretch="None"
        ClipToBounds="False"/>
</ui:CustomControl>


I think I found a solution. Wrapping my image inside a canvas solved the issue, probably due to the way canvas size is computed.


You need to Have a scroll viewer inside your custom control. Within the scroll viewer include the image control.

HTH

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜