I am trying to link to an external file, as in not in the compiled silverlight app, for my resource dictionary. I'd like to be able to drop 'themes' into a folder on my website and be able to use them without having to recompile and upload every time I create a new one.
I have it changing the resource successfully but I cannot figure out a way to link to a file that is not in the compiled application.
Here is what I have so far:
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();
}
I'd like to be able to change the '/DynamicDictionary;component/dict2.xaml' to something like 'http://localhost:9393/dict2.xaml' but it's giving me an error.
Anyone have any suggestions?
* EDIT **
It is giving me the following error when I try to reference it with localhost:
{System.UriFormatException: A relative URI cannot be created because the 'uriString' parameter represents an absolute URI. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind) at DynamicDictionary.MainPage.RedButtonClick(Object sender, RoutedEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}