【发布时间】:2011-07-13 13:55:57
【问题描述】:
我正在尝试为我的资源字典链接到一个外部文件,而不是在已编译的 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://localhost:9393/dict2.xaml”,但它给了我一个错误。
大家有什么建议吗?
* 编辑 **
当我尝试使用 localhost 引用它时,它给了我以下错误:
{System.UriFormatException: 一个相对的 无法创建 URI,因为 'uriString' 参数代表一个 绝对 URI。在 System.Uri.CreateThis(字符串 uri, Boolean 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 吃 System.Windows.Controls.Control.OnMouseLeftButtonUp(控制 ctrl, EventArgs e) 在 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex,Int32 实际参数类型索引,字符串 事件名称)}
【问题讨论】:
标签: c# silverlight resources