1

欢迎大家

基本上,在 Silverlight 4 或 5 中,我想调用Application.LoadComponent()给定的有效 xaml 内容。问题是,这个 xaml 是动态创建的,并且不存在于可用于 URI 的资源中。

通常,这会起作用:

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

但我需要类似的东西:

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

我不能使用XamlReader.Load(),因为我的 xaml 包含x:Class="...",这是这种方法不可接受的。

我要如何继续?我在想把字符串放进去MergedDictionary什么的,但是,如何让URI指向它呢?

4

0 回答 0