将自定义控件放在资源文件中 [英] Putting a custom control in a resource file
本文介绍了将自定义控件放在资源文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个控件,它是一个派生自ToggleButton的简单类,它控制背景
和前景
取决于 DataContext
的值。它在直接使用时可以找到,但是当在XML资源字典中使用它时会出现异常:
I created a control that is a simple class derived from a ToggleButton that controls the color of the Background
and Foreground
depending on values of the DataContext
. It works find when directly used, but I get an exception when this is used in an XML resource dictionary:
Cannot create unknown type ''{clr-namespace:Fox.UI.Module.OutlookBarTool.Controls}BrokerColorToggleButton''.
我之前尝试过使用某种行为对于同样的,但也得到了类似的错误。有什么想法吗?
I was trying previously to use a behaviour for the same, but also got a similar error. Any ideas?
推荐答案
这个说你可能使用了错误的Build Action
this one says that you might use incorrect Build Action
这篇关于将自定义控件放在资源文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文