【发布时间】:2016-10-30 20:21:56
【问题描述】:
我正在使用标签导航和页面,并想打开一个新页面。
在我的 app.xaml.cs 中,我创建了导航页面:
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new RootPage());
}
在 RootPage 中,我填写了 Navigation:
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之间切换更流畅?
感谢您的帮助:)
【问题讨论】:
标签: c# xaml xamarin navigation tabbedpage