Merged ResourceDictionary initalization in UWP app

和自甴很熟 提交于 2019-12-05 08:27:05

A ResourceDictionary in UWP doesn't have any code behind (no InitializeComponent). Therefore, any class references defined in a ResourceDictionary won't be initialized directly.

Neither does the App.InitializeComponent do this for you. Resource dictionaries in UWP just don't provide this functionallity - don't ask me why.

You can easily try this by trying to initialize a DataTemplate in a ResourceDictionary.
This should - sadly - neither work.

However, using the Resources["Locator"] access in code behind triggers the constructor of the class and you're fine.

This ain't be a solution, but a explanation of your problem. I hope it helps you.

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