简体   繁体   中英

Can I create Resources property for my own class?

I have class which doesn't have Resources property but I need a kind of resources in it. I tried to create it as ResourceDictionary and tried to work with it as it is common resource dictionary, but I get an exception when xaml-file is parsed. Should I do something special? Does anyone have such experience?

You should not be trying to create your own property to shoehorn into the existing resource system. Your class should be derived from FrameworkElement (or one of its derivatives) which has the common Resource property on it that works with the built in hierarchical resource system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM