当以下代码片段正在运行时(仅当用户开始使用tab [3]时),应用程序的行为会有所不同,具体取决于CurrentPage的更改方式:
以前有人处理过此事吗?如果它只是一个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);
};
}
}