• 导航基础 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);
    }
    }

  • 相关阅读:
    IOS开发-CALayer和UIView详细汇总
    IOS开发-第三方SDWebImage下载网络图片的使用
    解决TalbleView头部或底部子控件不显示问题
    node.js http.get 和http.post 数据
    Node.js Express 获取request原始数据
    个人开发者做一款Android App需要知道的事情
    个人开发者的酸甜苦辣
    码农的福利来了, 编程在线Androd 客户端上线了
    console使用技巧
    AngularJS 常用语法
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/2549087.html
Copyright © 2020-2023  润新知