usercontrol执行页面跳转

(一、一般的页面跳转)

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));







阅读更多
文章标签: object c# string
个人分类: silverlight/WP7
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭