SHARE
TWEET

Exception when adding a ResourceDictonary at runtime

a guest Feb 21st, 2012 9 Never
  1. var dictionaries = Resources.MergedDictionaries;
  2. dictionaries.Clear();
  3. string source = String.Format("/CommonUI;component/Resources/{0}.xaml", value == AppStyleSet.Light ? "WP7Style_Light" : "WP7Style_Dark");
  4. //base styles
  5. var themeStyles = new ResourceDictionary {Source = new Uri(source, UriKind.Relative)};
  6. dictionaries.Add(themeStyles);
  7. var generalStyles = new ResourceDictionary();
  8. generalStyles.Source = new Uri("/CommonUI;component/Resources/Styles.xaml",UriKind.Relative);
  9. dictionaries.Add(generalStyles);
  10.        
  11. ... <Setter Property="Color" Value="{StaticResource HighlightColor}" />
RAW Paste Data
Top