zoukankan      html  css  js  c++  java
  • 导航基础 GIS

    this.NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative)); 导航到SecondPage.xaml

    页面间传递参数,通过new uri (string  str)通过str 传递参数

    string destination = "/SecondPage.xaml";

    Color clr = (ContentPanel.Background as SolidColorBrush).Color;
    destination += String.Format("?Red={0}&Green={1}&Blue={2}",clr.R, clr.G, clr.B);

    this.NavigationService.Navigate(new Uri(destination, UriKind.Relative));

    SecondPage.xaml获得传递来的参数

    IDictionary<string, string> parameters = this.NavigationContext.QueryString;
    if (parameters.ContainsKey("Red"))
    {
    byte R = Byte.Parse(parameters["Red"]);
    byte G = Byte.Parse(parameters["Green"]);
    byte B = Byte.Parse(parameters["Blue"]);
    }

    多个页面之间都使用到的数据(共享数据)

    1image(在app 里面定义一个变量)

    (2)image在导航出去之前把用到的值保存到app 里面的变量)

    (3 )imageimage 在导航进去的页面 把值从app 的变量里面取出来

    在导航多个实例中保存页面数据

    image

    在导航出去之前把值存到PhoneApplicationService

    protected override void OnNavigatedFrom(NavigationEventArgs args)
    {
    if (ContentPanel.Background is SolidColorBrush)
    {
    Color clr = (ContentPanel.Background as SolidColorBrush).Color;
    if (args.Content is MainPage)
    (args.Content as MainPage).ReturnedColor = clr;
    PhoneApplicationService.Current.State["Color"] = clr;// 保存
    }
    }

    导航回来的时候把值从PhoneApplicationService取出来

    protected override void OnNavigatedTo(NavigationEventArgs args)
    {
    if (PhoneApplicationService.Current.State.ContainsKey("Color"))
    { Color clr = (Color)PhoneApplicationService.Current.State["Color"]; // 取出来

    ContentPanel.Background = new SolidColorBrush(clr);
    }
    }

  • 相关阅读:
    [CF1166E] The LCMs Must be Large
    AtCoder Beginner Contest 161
    [CF1168B] Good Triple
    [CF1172B] Nauuo and Circle
    [CF1185E] Polycarp and Snakes
    [CF1187E] Tree Painting
    Codeforces Round #631 (Div. 2)
    [CF1200E] Compress Words
    Thinkphp绕过宝塔getshell
    如何成为一个漏洞赏金猎人
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/2549087.html
Copyright © 2011-2022 走看看