删除选项卡后,Xamarin会标记导航错误

时间:2017-12-13 10:39:15

标签: xamarin xamarin.forms tabbedpage

当以下代码片段正在运行时(仅当用户开始使用tab [3]时),应用程序的行为会有所不同,具体取决于CurrentPage的更改方式:

  1. 如果用户将屏幕从标签[3]滑动到标签[2],则会按预期删除标签[3]。
  2. 如果用户选择了其中一个标签[0] - [2],则删除标签[3] 当前页面(正在显示)是标签左侧的一个标签用户已选中。
  3. 以前有人处理过此事吗?如果它只是一个Xamarin错误,任何想法如何操纵它?

    public partial class MainPage : TabbedPage
    {
        public MainPage()
        {
            InitializeComponent();
            //Some logic...
    
            ///Max number of tabs = 3, unless CurrentPage is the 4th tab.
            ///When CurrentPage is no longer the 4th tab, it will be removed.
            this.CurrentPageChanged += (object sender, EventArgs e) =>
            {
                 if ((CurrentPage == this.Children[0] || CurrentPage == this.Children[1] ||
                       CurrentPage == this.Children[2]) && this.Children.Count > 3)
                     this.Children.RemoveAt(3);
             };
        }
    }
    

    说明:

    • 我尝试删除的标签是在运行时通过其中一个标签生成的。
    • 目前我只在Android上测试了这种行为。
    • 我是Xamarin的初学者和一般开发的应用程序。事实上,这是我关于SO的第一个问题!

0 个答案:

没有答案
相关问题