WPF - TextBlock - Cannot override OnRender

∥☆過路亽.° 提交于 2019-12-11 11:52:53

问题


I 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.


回答1:


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



来源:https://stackoverflow.com/questions/2735387/wpf-textblock-cannot-override-onrender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!