我试图链接到外部文件,因为不在编译的silverlight应用程序中,用于我的资源字典。我希望能够将'主题'放到我网站上的文件夹中,并且能够使用它们,而无需每次创建新文件时重新编译和上传。Silverlight动态资源文件位置
我让它成功地更改了资源,但我找不到一种链接到不在编译的应用程序中的文件的方式。
这是我到目前为止有:
private void BlueButtonClick(object sender, RoutedEventArgs e)
{
var s = App.GetResourceStream(new System.Uri("/DynamicDictionary;component/dict2.xaml", System.UriKind.Relative)).Stream;
var reader = new StreamReader(s);
var xaml = reader.ReadToEnd();
var rdd = (ResourceDictionary)XamlReader.Load(xaml);
Resources.MergedDictionaries.Add(rdd);
VictoryIsMine();
}
我希望能够在“/DynamicDictionary;component/dict2.xaml”更改为类似的“http://本地主机:9393 /dict2.xaml',但它给了我一个错误。
任何人有任何建议吗?
*编辑**
这是给我下面的错误,当我尝试与本地主机引用它:
{System.UriFormatException:一个相对 URI不能因为创建 “uriString”参数表示绝对URI 。在 System.Uri.CreateThis(字符串URI, 布尔dontEscape,UriKind uriKind)
在System.Uri..ctor(字符串uriString中, UriKind uriKind)在 DynamicDictionary.MainPage.RedButtonClick(对象 发件人,RoutedEventArgs E)在 System.Windows.Controls.Primitives.ButtonBase.OnClick() 在 System.Windows.Controls.Button.OnClick() 在 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)上 System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl,EventArgs e)at MS .Internal.JoltHelper.FireEvent(IntPtr的 unmanagedObj,IntPtr的unmanagedObjArgs, 的Int32 argsTypeIndex,的Int32 actualArgsTypeIndex,字符串 eventName的)}
错误是什么? – VoodooChild 2011-03-11 15:23:17