Guest User

Untitled

a guest
Jun 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public static class BamlReader
  2. {
  3. public static object Load(Stream stream)
  4. {
  5. ParserContext pc = new ParserContext();
  6. MethodInfo loadBamlMethod = typeof(XamlReader).GetMethod("LoadBaml",
  7. BindingFlags.NonPublic | BindingFlags.Static)
  8. return loadBamlMethod.Invoke(null, new object[] { stream, pc, null, false });
  9. }
  10. }
  11.  
  12. // Usage:
  13. StreamResourceInfo sri = System.Windows.Application.GetResourceStream(
  14. new Uri("/MyAssemblyName;component/MyResourceDict.xaml", UriKind.Relative));
  15. ResourceDictionary resources = (ResourceDictionary)BamlReader.Load(sri.Stream);
Add Comment
Please, Sign In to add comment