开发者

How to load Resources in view level

开发者 https://www.devze.com 2023-03-04 06:35 出处:网络
Even thow it\'s the most comfortable way to merge all resources on application level it can also cost performance by loading all resources at startup. A better approach is to load only often used reso

Even thow it's the most comfortable way to merge all resources on application level it can also cost performance by loading all resources at startup. A better approach is to load only often used resources and load the other on view level.

How to load开发者_如何学运维 Resources in view level?


Put them in a resource dictionary and then merge the resource dictionary at the UserControl or Window level. For example:

<UserControl ...>
<UserControl.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="NameOfYourDictionary.xaml"/>
      <ResourceDictionary Source="Dictionary2.xaml"/>
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</UserControl.Resources>
</UserControl>
0

精彩评论

暂无评论...
验证码 换一张
取 消