I am using PRISM in combination with the Silverlight Toolkit. Now I try to apply a theme by using a code behind approach creating a Uri. If I place the XAML inside the shell project, everything works. But if I place it inside a module, the URI can't be resolved.
How do I need to change this URI?
ImplicitStyleManager.SetResourceDictionaryUri(this,
new Uri(@"CAL.Modules.Simple;component/WhistlerBlue.xaml",
UriKind.Relative));
ImplicitStyleManager.SetApplyMode(this, ImplicitStylesApplyMode.OneTime);
ImplicitStyleManager.Apply(this);
Is not working... What works is the following:
ImplicitStyleManager.SetResourceDictionaryUri(this, new Uri(@"WhistlerBlue.xaml",
UriKind.Relative));
ImplicitStyleManager.SetApplyMode(this, ImplicitStylesApplyMode.OneTime);
ImplicitStyleManager.Apply(this);
But only if I place the XAML inside the root of the shell project, which is far from nice...
Christian
PS: Question may be related to this, but I think this question here is more general (URI format for other DLL)...
Tried several other combinations (like changing the type of the XAML to embedded resource instead of content) or changing the name to the full name (CAL.Modules.Simple.WhistlerBlue.xaml) but still, no luck...
Perhaps its some basic PRISM / Toolkit related issue, I think I will do some more basic tests with two "native" Silverlight projects, and the creation of a simple URI for e.g. using an image from one assembly in another...
But still, if anyone has any ideas, help is welcome. By the way, did I mention, I start to really dislike URIs :-) These strange notations... And all the help you find when searching for tutorials are informations on "how to download images" or stuff like
this.. Nice, but I want to embed it :-)
I totally agree, the Uri stuff sucks big time. it is kind of hard to figure out. My 2 cents would be the following. The Xaml should have it's build action set to Resource. The Uri should start with "/". And that should work. I have had some issues with this
as well...so I took my findings and posted them on my blog -
http://chris.59north.com/post/Silverlight-3-MergedDictionaries.aspx
They are used in Xaml instead of in code behind, but it might help you a little I hope... Good luck!
You were right, the "miracle" was to set it to Resource, not Embedded Resource. And using the right notation, which in this example was:
ImplicitStyleManager.SetResourceDictionaryUri(this, new Uri(@"/CAL.Modules.Simple;component/Theme_Testing/Silverlight/WhistlerBlue.xaml", UriKind.Relative));
But still, if anybody from MS read this:
Please improve this somehow. I don't know how exactly, but something in the direction of strongly typed. Or better tools. The XAML, magic strings and runtime "not found, sorry" exceptions are a pain in... I tend to even code examples completly in C# now,
because Resharper can't refactor XAML cleanly (and he also does not know anything about Uris :-)
Strongly typed Uris :-) Not sure if that even makes sense, but it sound nice to me...
ChristianRup...
Member
8 Points
20 Posts
Uri Format for XAML from other DLL
Jul 30, 2009 03:27 PM | LINK
Hi,
I am using PRISM in combination with the Silverlight Toolkit. Now I try to apply a theme by using a code behind approach creating a Uri. If I place the XAML inside the shell project, everything works. But if I place it inside a module, the URI can't be resolved. How do I need to change this URI?
Is not working... What works is the following:
But only if I place the XAML inside the root of the shell project, which is far from nice...
Christian
PS: Question may be related to this, but I think this question here is more general (URI format for other DLL)...
elmore.adam
Member
482 Points
67 Posts
Re: Uri Format for XAML from other DLL
Jul 30, 2009 10:08 PM | LINK
new Uri(@"/CAL.Modules.Simple;component/WhistlerBlue.xaml", UriKind.Relative));
Kind Regards
Adam Elmore
MCTS: WPF, WCF
417.200.4261
elmore.adam@gmail.com
http://adamelmore.net/
ChristianRup...
Member
8 Points
20 Posts
Re: Uri Format for XAML from other DLL
Jul 30, 2009 10:29 PM | LINK
No, sorry, did not work.
Tried several other combinations (like changing the type of the XAML to embedded resource instead of content) or changing the name to the full name (CAL.Modules.Simple.WhistlerBlue.xaml) but still, no luck...
Perhaps its some basic PRISM / Toolkit related issue, I think I will do some more basic tests with two "native" Silverlight projects, and the creation of a simple URI for e.g. using an image from one assembly in another...
But still, if anyone has any ideas, help is welcome. By the way, did I mention, I start to really dislike URIs :-) These strange notations... And all the help you find when searching for tutorials are informations on "how to download images" or stuff like this.. Nice, but I want to embed it :-)
Chris
ZeroKoll
Participant
764 Points
132 Posts
Re: Uri Format for XAML from other DLL
Aug 03, 2009 12:52 AM | LINK
I totally agree, the Uri stuff sucks big time. it is kind of hard to figure out. My 2 cents would be the following. The Xaml should have it's build action set to Resource. The Uri should start with "/". And that should work. I have had some issues with this as well...so I took my findings and posted them on my blog - http://chris.59north.com/post/Silverlight-3-MergedDictionaries.aspx
They are used in Xaml instead of in code behind, but it might help you a little I hope... Good luck!
ChristianRup...
Member
8 Points
20 Posts
Re: Uri Format for XAML from other DLL
Aug 03, 2009 02:30 AM | LINK
Thanks a lot, finally got it...
You were right, the "miracle" was to set it to Resource, not Embedded Resource. And using the right notation, which in this example was:
ImplicitStyleManager.SetResourceDictionaryUri(this, new Uri(@"/CAL.Modules.Simple;component/Theme_Testing/Silverlight/WhistlerBlue.xaml", UriKind.Relative));
But still, if anybody from MS read this:
Please improve this somehow. I don't know how exactly, but something in the direction of strongly typed. Or better tools. The XAML, magic strings and runtime "not found, sorry" exceptions are a pain in... I tend to even code examples completly in C# now, because Resharper can't refactor XAML cleanly (and he also does not know anything about Uris :-)
Strongly typed Uris :-) Not sure if that even makes sense, but it sound nice to me...