2010-02-24 41 views

回答

4

肯定。 你想看看什麼是XamlReader類,specefically,XamlReader.Load

+0

這聽起來像它正是我要找的。謝謝。 – 2010-02-24 04:33:16

0

E.g:

string xaml = 
@"<DataTemplate> 
    @"<TextBlock Text=""{{Binding Converter={{StaticResource templatesConverter}}, {0} }}""/> 
    @"</DataTemplate>"; 

MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(xaml)); 

ParserContext context = new ParserContext(); 

context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); 

context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml"); 

DataTemplate datatemplate = (DataTemplate)XamlReader.Load(stream, context); 
相關問題