取消在Wpf中呈现控件 [英] Cancel rendering of a Control in Wpf
问题描述
亲爱的所有人,
我环顾四周,找到了解决我问题的优雅方法,但没有成功的记录……[叹气]
我想防止基于条件(实际上是数据库链接的安全检查)呈现(绘制,绘制..?)控件(自定义标签,自定义按钮等),但不能使用可见性或不透明度属性因为我想让这些属性在设计模式下可供控件的用户自由使用.
我尝试重写OnRender,传递null的drawingContext等,但是它不起作用.
有人有一个想法怎么做吗?
谢谢!
Dear all,
I''ve looked around to find an elegant solution to my problem, but not with a log of success... [sigh]
I would like to prevent a control (custom label, custom button,...) from being rendered (drawn, painted.. ?) based on a condition (actually, a database linked security check)
but not by using the visibility or opacity properties as I would like to keep these properties freely usable by the users of the control in design mode.
I tried to override OnRender, passing a null drawingContext etc. but it doesn''t work.
Does anyone have an idea how to do this ?
Thanks all!
推荐答案
如有必要,您始终可以为控件创建一个空样式.
应用DataTrigger进行应用这种样式根据您的情况而定.
You could always create an empty style for the control if necessary.
Apply a DataTrigger to apply this style based on your condition.
这篇关于取消在Wpf中呈现控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!