Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -050017260567http://forums.silverlight.net//p/115581/260567.aspx/1?Uri+Format+for+XAML+from+other+DLLUri Format for XAML from other DLL <p>Hi,</p> <p>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?</p> <p>&nbsp;</p> <pre class="prettyprint"> ImplicitStyleManager.SetResourceDictionaryUri(<span class="kwd">this</span>, <span class="kwd">new</span> Uri(@<span class="st">"CAL.Modules.Simple;component/WhistlerBlue.xaml"</span>, UriKind.Relative)); ImplicitStyleManager.SetApplyMode(<span class="kwd">this</span>, ImplicitStylesApplyMode.OneTime); ImplicitStyleManager.Apply(<span class="kwd">this</span>);</pre><p>&nbsp;&nbsp;</p><p>Is not working... What works is the following:</p><p>&nbsp;</p><pre class="prettyprint"> ImplicitStyleManager.SetResourceDictionaryUri(<span class="kwd">this</span>, <span class="kwd">new</span> Uri(@<span class="st">"WhistlerBlue.xaml"</span>, UriKind.Relative)); ImplicitStyleManager.SetApplyMode(<span class="kwd">this</span>, ImplicitStylesApplyMode.OneTime); ImplicitStyleManager.Apply(<span class="kwd">this</span>);</pre> <p><br> But only if I place the XAML inside the root of the shell project, which is far from nice...</p> <p>Christian</p> <p>&nbsp;</p> <p>PS: Question may be <a href="/forums/t/115373.aspx">related </a>to this, but I think this question here is more general (URI format for other DLL)...</p> <p>&nbsp;</p> 2009-07-30T14:27:35-04:00260853http://forums.silverlight.net//p/115581/260853.aspx/1?Re+Uri+Format+for+XAML+from+other+DLLRe: Uri Format for XAML from other DLL I'm fairly certain that a leading forward slash (&quot;/&quot;) is required: <br> <br> new Uri(@&quot;/CAL.Modules.Simple;component/WhistlerBlue.xaml&quot;, UriKind.Relative)); 2009-07-30T21:08:41-04:00260884http://forums.silverlight.net//p/115581/260884.aspx/1?Re+Uri+Format+for+XAML+from+other+DLLRe: Uri Format for XAML from other DLL <p>&nbsp;No, sorry, did not work.</p> <p>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...</p> <p>&nbsp;Perhaps its some basic PRISM / Toolkit related issue, I think I will do some more basic tests with two &quot;native&quot; Silverlight projects, and the creation of a simple URI for e.g. using an image from one assembly in another...</p> <p>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 &quot;how to download images&quot; or stuff like this.. Nice, but I want to embed it :-)</p> <p>Chris <br> </p> 2009-07-30T21:29:16-04:00262016http://forums.silverlight.net//p/115581/262016.aspx/1?Re+Uri+Format+for+XAML+from+other+DLLRe: Uri Format for XAML from other DLL <p>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 &quot;/&quot;. And that should work. I have had some issues with this as well...so I took my findings and posted them on my blog - <a href="http://chris.59north.com/post/Silverlight-3-MergedDictionaries.aspx"> http://chris.59north.com/post/Silverlight-3-MergedDictionaries.aspx</a></p> <p>They are used in Xaml instead of in code behind, but it might help you a little I hope... Good luck!</p> 2009-08-02T23:52:06-04:00262038http://forums.silverlight.net//p/115581/262038.aspx/1?Re+Uri+Format+for+XAML+from+other+DLLRe: Uri Format for XAML from other DLL <p>&nbsp;Thanks a lot, finally got it...</p> <p>You were right, the &quot;miracle&quot; was to set it to Resource, not Embedded Resource. And using the right notation, which in this example was:</p> <p>ImplicitStyleManager.SetResourceDictionaryUri(this, new Uri(@&quot;/CAL.Modules.Simple;component/Theme_Testing/Silverlight/WhistlerBlue.xaml&quot;, UriKind.Relative));</p> <p>But still, if anybody from MS read this:</p> <p>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 &quot;not found, sorry&quot; 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 :-)</p> <p>Strongly typed Uris :-) Not sure if that even makes sense, but it sound nice to me... <br> </p> <p>&nbsp;<br> </p> 2009-08-03T01:30:59-04:00