官术网_书友最值得收藏!

Multi-page views

CarouselPage and TabbedPage are two Xamarin.Forms page implementations that derive from the MultiPage abstraction. These pages can each host multiple pages with unique navigation between them.

To illustrate the usage of MultiPage implementations, we can utilize our previously implemented pages:

 <?xml version="1.0" encoding="UTF-8"?>
<CarouselPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="using:FirstXamarinFormsApplication.Client"
x:Class="FirstXamarinFormsApplication.Client.ItemsCarousel">
<CarouselPage.Children>
<local:ListItemView BindingContext="{Binding .}" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[0]}" Title="First" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[1]}" Title="Second" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[2]}" Title="Third" Icon="Xamarin.png"/>

</CarouselPage.Children>
</CarouselPage>

In a similar fashion, we can create our tabbed page using the list and item details view pages:

 <?xml version="1.0" encoding="UTF-8"?>
<TabbedPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:local="using:FirstXamarinFormsApplication.Client"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FirstXamarinFormsApplication.Client.ItemsTabbed">
<TabbedPage.Children>
<local:ListItemView BindingContext="{Binding .}" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[0]}" Title="First" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[1]}" Title="Second" Icon="Xamarin.png"/>
<local:ItemView BindingContext="{Binding Items[2]}" Title="Third" Icon="Xamarin.png"/>
</TabbedPage.Children>
</TabbedPage>

The resulting pages would, in fact, host all the children in their respective layout and navigation methods (tabs versus swipe gestures):

It is important to note that, on iOS, the title and icon properties of children are used to create tabbed navigation items. In order for icons to display properly, the image that is used should be 30x30 for normal resolution, 60x60 for high resolution, and 90x90 for iPhone 6 resolution. On Android, the title is used to create tab items.

In particular, TabbedPage is one of the fundamental controls used in iOS applications at the top of the navigation hierarchy. TabbedPage implementation can be extended by creating a navigation stack for each of the tabs separately. This way, navigating between tabs preserves the navigation stack for each tab independently, with support for navigating back and forth:

主站蜘蛛池模板: 商洛市| 正镶白旗| 和田市| 平罗县| 连山| 兴和县| 绥滨县| 闵行区| 黄山市| 卢氏县| 惠州市| 洮南市| 绍兴县| 大石桥市| 潞城市| 临猗县| 香港 | 门源| 公主岭市| 如东县| 朝阳县| 甘洛县| 纳雍县| 阳春市| 聂拉木县| 罗定市| 东宁县| 南投市| 丹寨县| 邹平县| 赞皇县| 峡江县| 临漳县| 荥阳市| 宜川县| 金溪县| 深圳市| 达拉特旗| 新丰县| 西青区| 宁安市|