public async Task <ResourceDictionary> TryLoadResourceDictionary(AppTheme theme) { StorageFile file; if (theme?.Path == null) { return(null); } if (theme.AbsolutePath.Contains(ImportedThemesFolder.Path)) { file = await ImportedThemesFolder.GetFileAsync(theme.Path); theme.IsImportedTheme = true; } else { file = await ThemeFolder.GetFileAsync(theme.Path); theme.IsImportedTheme = false; } var code = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(code) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); return(xaml); }
public async Task <ResourceDictionary> TryLoadResourceDictionary(AppTheme theme) { StorageFile file; if (theme?.Path == null) { return(null); } if (theme.IsFromOptionalPackage) { if (OptionalPackageThemesFolder != null) { file = await OptionalPackageThemesFolder.GetFileAsync(theme.Path); } else { return(null); } } else { file = await ThemeFolder.GetFileAsync(theme.Path); } var code = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(code) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); return(xaml); }
public async Task <bool> TryLoadThemeAsync(AppTheme theme) { try { StorageFile file; if (theme.IsFromOptionalPackage) { if (OptionalPackageThemeFolder != null) { file = await OptionalPackageThemeFolder.GetFileAsync(theme.Path); } else { return(false); } } else { file = await ThemeFolder.GetFileAsync(theme.Path); } CurrentThemeResources = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(CurrentThemeResources) as ResourceDictionary; xaml.Add("CustomThemeID", theme.Key); App.Current.Resources.MergedDictionaries.Add(xaml); return(true); } catch (Exception) { return(false); } }
public async Task <bool> TryLoadThemeAsync(string name) { try { var file = await ThemeFolder.GetFileAsync(name); CurrentThemeResources = await FileIO.ReadTextAsync(file); var xaml = XamlReader.Load(CurrentThemeResources) as ResourceDictionary; App.Current.Resources.MergedDictionaries.Add(xaml); return(true); } catch (Exception) { return(false); } }