【发布时间】:2011-04-10 19:31:15
【问题描述】:
我在自定义 ContentControl 中有一个 Image 控件,用于应用一些转换(通过 RenderTransform 进行缩放和转换)。问题是,对于大于控件区域的图像,如果我滚动或缩小,它会像在原始视口中一样被剪裁。
有没有办法强制图像完全绘制自己? (已经尝试将 ClipToBounds 设置为 false)
顺便说一句,如果我尝试将图像作为画布的背景,它可以正常工作。
编辑,这里有一些细节。
我的控制:
public class CustomControl: ContentControl
设置阶段:
source = VisualTreeHelper.GetChild(this, 0) as FrameworkElement;
...
source.RenderTransform = this.transformGroup;
变换组由平移和缩放变换组成。
xaml 部分是这样的:
<ui:CustomControl ClipToBounds="True">
<Image
Source="{Binding Path=BackgroundImage}"
Stretch="None"
ClipToBounds="False"/>
</ui:CustomControl>
【问题讨论】:
-
你能发布相关的 XAML 吗?您将转换应用于哪个元素,图像或内容控件?
标签: wpf