【问题标题】:Xamarin.Forms Load different pages on ClickEvent on TabbedPageXamarin.Forms 在 TabbedPage 上的 ClickEvent 上加载不同的页面
【发布时间】:2016-03-15 20:02:17
【问题描述】:

我正在研究 Xamarin.Forms,我遇到了一种情况,即必须在 Tabs 上呈现 4 个不同的 (ContentPage) 页面。所以我正在使用 TabbedPage 并向父页面添加不同的分页。现在的问题是当我来到 tabbedpage 时,所有 4 个页面都在不同的选项卡上呈现。有什么办法可以让我看到 4 个选项卡,但是当在单击事件时单击特定选项卡时,它应该动态加载页面。

Page_1 = new Page_1() { Title = "Page_1" , Icon="icon_1.png"};
Page_2 = new Page_2() { Title = "Page_2", Icon="icon_2png"};
Page_3 = new Page_3() { Title = "Page_3", Icon="icon_3.png"};
Page_4 = new Page_4() { Title = "page_4, Icon="icon_4.png"};

Children.Add(Page_1);
Children.Add(Page_2);
Children.Add(Page_3);
Children.Add(Page_4);

我想动态加载所有页面。有什么帮助吗?

【问题讨论】:

    标签: xamarin xamarin.android xamarin.forms xamarin-studio xamarin.mac


    【解决方案1】:

    在你的内容页面做

    private bool _appeared = false;
    public override void OnAppearing()
    {
         base.OnAppearing();
    
         // To avoid repeating loading it. Remove if you want to refresh every time.
         if (!_appeared) 
         {
               // Load from here
    
    
            _appeared = true;
         }
    }
    

    这样他们只在页面被查看时加载

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-11
      • 2017-02-12
      • 2021-03-23
      • 1970-01-01
      • 1970-01-01
      • 2019-10-26
      • 2018-06-24
      • 1970-01-01
      相关资源
      最近更新 更多