Last active
July 3, 2017 14:15
-
-
Save JKamsker/2442e8e9177525c862aee771d402abbb to your computer and use it in GitHub Desktop.
Add merged directories from the codebehind
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sample Usage for mahapps: | |
//WpfDictionaries.AddDirectories("MahApps.Metro", "component/Styles", new string[] { "Controls", "Fonts", "Colors", "Accents/Blue", "Accents/BaseLight" }, "xaml"); | |
internal class WpfDictionaries | |
{ | |
public static void AddDirectories(string domain, string prefix, IEnumerable<string> fileNames, string suffix) | |
{ | |
fileNames.ForEach(x => | |
{ | |
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary | |
{ | |
Source = new Uri($"pack://application:,,,/{domain};{prefix}/{x}.{suffix}", UriKind.RelativeOrAbsolute) | |
}); | |
}); | |
} | |
} | |
internal static class Extensions{ | |
public static void ForEach<T>(this IEnumerable<T> input, Action<T> toRunAct) | |
{ | |
foreach (var put in input) | |
{ | |
toRunAct(put); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment