假设我的应用中有四个页面。假设它们是 Acs.xaml、MainPage.xaml、Home.xaml 和 Weather.xaml。(因为我正在使用访问控制服务 (ACS) 来执行身份验证功能)。
现在,经过身份验证后,ACS 将我重定向到 MainPage.xml 和 MainPage.xaml 上有两个按钮,其中一个将用户带到 Home,而另一个将用户带到 Weather。
现在,当我在主页上时,我想要另一个按钮将它们带到天气。同样,当我在 Weather 时,我想要一个按钮将它们带回家。(在 Home.xaml 和 Weather.xaml 中,我正在使用图表,使用数据可视化工具包的图表 [Silverlight)
我已经浏览了 windowsteamblog(循环导航),但没有任何工作正常......当我到达 MainPage.xaml 并单击任何按钮时,我得到一个错误,比如导航失败,我也尝试了全景但无法解决问题。
登录页面代码:-
namespace PhoneApp1.Pages
{
using System;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.WindowsAzure.Samples.Phone.Identity.AccessControl
public partial class LoginPage : PhoneApplicationPage
{
private readonly SimpleWebTokenStore swtStore = Application.Current.Resources["swtStore"] as SimpleWebTokenStore;
public LoginPage()
{
this.InitializeComponent();
this.PageTransitionReset.Begin();
this.SignInControl.RequestSimpleWebTokenResponseCompleted +=
(s, e) =>
{
// The ACS token was successfully received and stored in the "swtStore" application resource.
// TODO: Navigate to your main page i.e.:
this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
};
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if ((e.NavigationMode == NavigationMode.New) && this.swtStore.IsValid())
{
// There is a valid ACS token already in the "swtStore" application resource.
// TODO: Navigate to your main page i.e.:
this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
else
{
// There is not a valid ACS token in the "swtStore" application resource.
// The token may be expired or it is the first time the user logs in.
this.PageTransitionIn.Begin();
this.SignInControl.GetSimpleWebToken();
}
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
this.PageTransitionReset.Begin();
}
}
}`
主页代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Controls.DataVisualization.Charting;
namespace Chart
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new System.Uri(@"/Home.xaml", UriKind.RelativeOrAbsolute));
}
private void button2_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new System.Uri(@"/Weather.xaml", UriKind.RelativeOrAbsolute));
}
}
}`