|
|||||||||||||
How to load BAML resourcesWhat is BAML?WPF is based on XAML an XML dialect to describe object graphs. This is very powerful but parsing an XAML file at runtime is quite expensive. So the The BAML API is something unique of WPF and was not public until .NET 4.0. Now it's available through the Load an object from a BAML streamLoad a BAML stream in .NET 3.5 (by using reflection): var pc = new ParserContext(); var readerType = presentationFrameworkAssembly .GetType("System.Windows.Markup.XamlReader"); var method = readerType.GetMethod("LoadBaml", BindingFlags.NonPublic | BindingFlags.Static); return method.Invoke(null, new object[] {stream, pc, null, false}); Load a BAML stream in .NET 4.0: var reader = new Baml2006Reader(stream); var writer = new XamlObjectWriter(reader.SchemaContext); while(reader.Read()) { writer.WriteNode(reader); } return writer.Result;
Last modified: 2011-03-14 20:49:21
Copyright (c) by Christian Moser, 2011.
Comments on this articleShow all comments
|
|||||||||||||