关闭

usercontrol执行页面跳转

标签: objectc#string
680人阅读 评论(0) 收藏 举报
分类:

(一、一般的页面跳转)

XAML

<HyperlinkButton NavigateUri="SecondPage.xaml" />

C# for MainPage.xaml.cs

private void MyButton_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/SecondPage.xaml",
UriKind.RelativeOrAbsolute));
}

C# for SecondPage.xaml.cs

private void BtnBack_Click(object sender, RoutedEventArgs e)
{
if (NavigationService.CanGoBack)
NavigationService.GoBack();
}
传参数

C# for MainPage.xaml.cs

private void MyButton_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" +
MyTB.Text, UriKind.RelativeOrAbsolute));
}

C# for SecondPage.xaml.cs

protected override void OnNavigatedTo
(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string msg = "";
if (NavigationContext.QueryString.TryGetValue("msg", out msg))
MyTBl.Text = msg;
}
(二、通过App.Current.RootVisual

App app=Application.Current as App;
app.RootVisual=new older_homepage();


var root = App.Current.RootVisual as PhoneApplicationFrame;
 root.Navigate(new Uri("/older/older_homepage.xaml", UriKind.RelativeOrAbsolute));







0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1266581次
    • 积分:16354
    • 等级:
    • 排名:第625名
    • 原创:372篇
    • 转载:805篇
    • 译文:0篇
    • 评论:94条
    最新评论