开发者

How do I get OnRender to be called when a parent UIElement's RenderTransform is changed?

I have a System.Windows.Controls.Image derived class that needs notification that the parent UIElement's RenderTransform has changed (say a zoom occurred). I want to be able to limit whats kept in memory so that I'm not keeping a huge image in memory when only a small portion is visible, as well as decrease the resolution when the image开发者_如何学JAVA is zoomed out. Is there a way to force OnRender to be called on my Image? I know AffectsRender can be set on the parent's RenderTransformProperty, but that doesn't trickle down to my Image...any ideas?


It feels a bit of a hack to me, but you can introduce a new Dependency Property on your image that has AffectsRender = true. The DP should be of type object, and you should Bind it to the RenderTransform of its parent. Thus, when RenderTransform of the parent changes, the child's DP would make the child re-render itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜