1 ///
2 /// 解析第三方应用调用参数
3 ///
4 class AssociationUriMapper : UriMapperBase
5 {
6 private string tempUri;
7
8 public override Uri MapUri(Uri uri)
9 {
10 tempUri = uri.ToString();
11
12 // Protocol association launch for contoso.
13 if (tempUri.Contains("/Protocol"))
14 {
15 int pos = tempUri.IndexOf("encodedLaunchUri");
16 String encodedString = tempUri;
17 if (pos >= 0)
18 {
19 encodedString = tempUri.Substring(pos);
20 }
21 return new Uri("/MainPage.xaml?" + encodedString, UriKind.Relative);
22 }
23
24 // Include the original URI with the mapping to the main page.
25 return new Uri("/MainPage.xaml", UriKind.Relative);
26 }
27 }
3.修改App.xaml.cs文件的InitializePhoneApplication,添加:
1 // Assign the URI-mapper class to the application frame.
2 RootFrame.UriMapper = new AssociationUriMapper();
4.修改MainPage.xaml.cs文件,添加提示框,弹出传人的URI,代码如下: