在 Windows Phone 7 中导航到不同程序集中的 XAML 页面 [英] Navigate to a XAML page in a different assembly in Windows Phone 7

查看:18
本文介绍了在 Windows Phone 7 中导航到不同程序集中的 XAML 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单独的 Windows Phone 类库中有一个 XAML 页面.该库包含在我的 VS 解决方案中,并从我的应用项目中引用.假设该页面名为 TestPage.xaml,它位于我的名为 SharedPages 的库的根文件夹中.

I have a XAML page in a separate Windows Phone class library. The library is included in my VS solution and referenced from my app project. Let's say the page is called TestPage.xaml and it's in the root folder of my library called SharedPages.

我想使用 NavigationService 在我的应用中导航到此页面.我发现 这篇文章 建议使用这种 URI 格式:

I'd like to navigate to this page in my app using the NavigationService. I found this post which suggests using this URI format:

/{assemblyName};component/{pathToResource}

所以我正在尝试这样的事情:

So I'm trying something like this:

NavigationService.Navigate(new Uri("/SharedPages;component/TestPage.xaml"));

当我运行它时,我得到以下异常:

When I run this I get the following exception:

仅支持对作为片段、或以/"开头或包含;component/"的相对 URI 进行导航.

我做错了什么?

谢谢.

推荐答案

看起来需要将 URI 创建为相对 URI.这有效:

Looks like the URI needs to be created as a relative URI. This works:

NavigationService.Navigate(new Uri("/SharedPages;component/TestPage.xaml", UriKind.Relative));

这篇关于在 Windows Phone 7 中导航到不同程序集中的 XAML 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆