Read WPF ResourceDictionaries from WinForms
29-12-2015 14:20:28
C# / WPF
0 Bookmark(s)
243 View(s)
public static class BamlReader
{
public static object Load(Stream stream)
{
ParserContext pc = new ParserContext();
MethodInfo loadBamlMethod = typeof(XamlReader).GetMethod("LoadBaml",
BindingFlags.NonPublic | BindingFlags.Static)
return loadBamlMethod.Invoke(null, new object[] { stream, pc, null, false });
}
}
StreamResourceInfo sri = System.Windows.Application.GetResourceStream(
new Uri("/MyAssemblyName;component/MyResourceDict.xaml", UriKind.Relative));
ResourceDictionary resources = (ResourceDictionary)BamlReader.Load(sri.Stream);