Saturday, October 6, 2012

Silverlight LoadComponent from string

Silverlight LoadComponent from string

Welcome all

Basically, in Silverlight 4 or 5, I would like to call Application.LoadComponent() for a given valid xaml content. The problem is, that this xaml is dynamically created, and is not present in resource available for URI.

Normally, this would work:

System.Windows.Application.LoadComponent(this,      new System.Uri("/TestApp;component/MainPage.xaml")); 

but I need something like:

string s = "{some xaml}"; System.Windows.Application.LoadComponent(this, s); 

I cannot use XamlReader.Load(), because my xaml contains x:Class="...", which is not acceptable by this method.

How can I go on? I was thinking to put the string into MergedDictionary or something, but then, how to make the URI to point it?

Answers & Comments...




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog