1 2 3 4 5 6 7 8 9 10 11 12
|
string assName = Assembly.GetExecutingAssembly().GetName().Name;
byte[] byteArray = Encoding.ASCII.GetBytes( str );
MemoryStream xmlStream = new MemoryStream(byteArray);
ParserContext pc = new ParserContext();
pc.XamlTypeMapper = new XamlTypeMapper(new string[] { assName });
pc.XmlnsDictionary.Add( "av", "http://schemas.microsoft.com/winfx/2006/xaml/presentation" );
pc.XmlnsDictionary.Add( "x", "http://schemas.microsoft.com/winfx/2006/xaml" );
pc.XmlnsDictionary.Add( "sys", "clr-namespace:System;assembly=mscorlib" );
UserControl obj = XamlReader.Load(xmlStream, pc) as UserControl;
this.grid.Children.Add(obj); |
Partager