C# Silverlight动态资源文件位置
我正在尝试为我的资源字典链接到外部文件,而不是在已编译的silverlight应用程序中。我希望能够将“主题”放到我网站上的文件夹中,并且能够使用它们,而无需每次创建新主题时重新编译和上传 我让它成功地更改了资源,但我无法找到链接到已编译应用程序中不存在的文件的方法 以下是我到目前为止的情况:C# Silverlight动态资源文件位置,c#,silverlight,resources,C#,Silverlight,Resources,我正在尝试为我的资源字典链接到外部文件,而不是在已编译的silverlight应用程序中。我希望能够将“主题”放到我网站上的文件夹中,并且能够使用它们,而无需每次创建新主题时重新编译和上传 我让它成功地更改了资源,但我无法找到链接到已编译应用程序中不存在的文件的方法 以下是我到目前为止的情况: private void BlueButtonClick(object sender, RoutedEventArgs e) { var s = App.GetResourceStream(new S
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.at
CreateThis(字符串Uri,
布尔顿特斯卡普,UriKind UriKind)在System.Uri..ctor(字符串uriString, 乌里金(乌里金) DynamicDictionary.MainPage.RedButton单击(对象 发送者,路由EventTargets 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(控件 ctrl,EventArgs e)在 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj,IntPtr unmanagedobjars, Int32 argsTypeIndex,Int32 ActualLargsTypeIndex,字符串 事件名称)}
没有一种切实可行的方法可以直接从文件外部获取它 我知道你有两个选择(不是说没有其他选择,但我认为这是通常的做法):