Dynamically loading resource dictionary files to a wpf application gives an error

前端 未结 3 1125
天命终不由人
天命终不由人 2020-12-03 12:08

I am trying to add a xaml resource file dynamically using the statement,

Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Sou         


        
3条回答
  •  Happy的楠姐
    2020-12-03 12:28

    At last, it worked. Here is what I did,

    1. Went thru' http://msdn.microsoft.com/en-us/library/aa970069.aspx.
    2. Changed the Uri pattern to

      var foo = new Uri("pack://siteoforigin:,,,/resources/leaf_styles.xaml", UriKind.RelativeOrAbsolute);
      Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = foo });
      

提交回复
热议问题