我正在使用标签导航和页面,并且想要打开一个新页面。
在我的 app.xaml.cs 中,我创建了导航页面:
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new RootPage());
}
在 RootPage 我填写导航:
public RootPage()
{
NavigationPage.SetHasNavigationBar(this, false);
Children.Add(new TestPage1
{
Title = "TestPage1"
});
Children.Add(new TestPage2
{
Title = "TestPage2"
});
Children.Add(new TestPage3
{
Title = "TestPage3"
});
}
这种类型的导航已经很好地工作并且看起来不错。现在我想在 TestPage3 中打开一个新页面:TestPage3.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoApplication.TestPage3">
<Button x:Name="openSetup" Clicked="ItemClicked" Text="open Settings"/>
</ContentPage>
TestPage3.xaml.cs:
namespace DemoApplication
{
public partial class TestPage3 : ContentPage
{
public TestPage3()
{
InitializeComponent();
}
void ItemClicked(object sender, EventArgs e)
{
Navigation.PushAsync(new TestPage4());
}
}
}
这也有效,但看起来不太好。
新内容加载在原始选项卡导航下方,加载后选项卡导航消失 - 所以 Page4 的内容有点跳跃:)
在 soundcloud 等其他应用程序中,它们的功能相同,但看起来更流畅。
有没有什么办法可以让tab-navigation在back-navigation之间切换更顺畅?
谢谢你的帮助 :)