开发者

Silverlight: how to navigate to page in class library

开发者 https://www.devze.com 2023-01-06 13:46 出处:网络
I have a bunch of reusable pages that I want to put into a class library.So I have edited my MainPage.xml (\'Moe.Tactical.Generic.Silverlight\' is the name of the class library)

I have a bunch of reusable pages that I want to put into a class library. So I have edited my MainPage.xml ('Moe.Tactical.Generic.Silverlight' is the name of the class library)

<uriMapper:UriMapper>
  <uriMapper:UriMapping Uri="/Views/{path}" MappedUri="/Moe.Tactical.Generic.Silverlight;component/Views/{path}" />开发者_开发百科;
  <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>

Then I assign the url in code, but I get the error: Page not found: "/Moe.Tactical.Generic.Silverlight;component/Views/GenericView?page=Maintanance"

I assign the Uri via

return new Uri(@"/" + pageType + "?page=" + page.Name, UriKind.Relative);

have I missed something?


Sorry -- my first answer didn't apply. In your case, your mapping looks like this:

  <uriMapper:UriMapping Uri="/Views/{path}" MappedUri="/Moe.Tactical.Generic.Silverlight;component/Views/{path}" />

The Uri you've tried to navigate to doesn't match this pattern. You'll end up with something like: "/MyPageType?page=SomeName", which doesn't match "/Views/{path}". To make your Uri match the pattern, consider something like:

return new Uri(@"/Views/" + pageType + ".xaml?page=" + page.Name, UriKind.Relative); 

Note the extra "Views/" and ".xaml" in the Uri compared to the example you have in your question.

0

精彩评论

暂无评论...
验证码 换一张
取 消