WPF - TextBlock - 不能重写OnRender [英] WPF - TextBlock - Cannot override OnRender
问题描述
我通过派生TextBlock来创建自定义控件,我的意图是根据一些依赖属性来做一些自定义的渲染。但是,OnRender方法被封装在TextBlock上。虽然我可以通过覆盖OnRenderSizeChanged来完成我的工作,但这是不正确的。任何想法,我怎么能做到这一点正确的方式?
在此先感谢。
阅读更多:
a href =http://msdn.microsoft.com/en-us/library/system.windows.controls.controltemplate(v=VS.100).aspx =nofollow noreferrer> http:// msdn。 microsoft.com/en-us/library/system.windows.controls.controltemplate(v=VS.100).aspxI am creating a custom control by deriving TextBlock, my intention is to do some custom rendering based on some dependency properties. However the OnRender method is sealed on TextBlock. Although I can get my work done by overriding OnRenderSizeChanged, this is not correct. Any ideas on how can i do it the right way?
Thanks in advance.
In WPF you normally work with styles or Control templates to change the appearance of a control. You can download templates for all controls from Microsoft and play around with them.
Read more here:
http://msdn.microsoft.com/en-us/library/system.windows.controls.controltemplate(v=VS.100).aspx
这篇关于WPF - TextBlock - 不能重写OnRender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!