【发布时间】:2018-01-07 20:42:09
【问题描述】:
当我尝试将Navigation 添加到我的CropsListPage 时遇到一个奇怪的错误
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-Balloney.Views"
x:Class="Balloney.Views.MainPage">
<NavigationPage Icon="carrot.png">
<x:Arguments>
<local:CropListPage/>
</x:Arguments>
</NavigationPage>
<ContentPage Icon="search.png"></ContentPage>
</TabbedPage>
然后它导致..
如果我不尝试将其封装在 NavigationPage 中,它会保持正常
知道是什么导致了这种行为吗?在尝试解决这个问题并在 Android 中硬编码状态栏的大小之前,我正在寻找一种方法来理解问题并防止它发生。谢谢
MainPage.xaml 正在工作
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Balloney.Views"
x:Class="Balloney.Views.MainPage">
<local:CropListPage Icon="carrot.png"/>
<ContentPage Icon="search.png"></ContentPage>
</TabbedPage>
还有CropListxaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Balloney.Views.CropListPage">
<ListView ItemsSource="{Binding CropsList}" ItemTapped="OnCropTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Image Source="{Binding ImageUrl}" VerticalOptions="Fill" WidthRequest="50"/>
<StackLayout HorizontalOptions="StartAndExpand">
<Label Text="{Binding Specie.Name}"/>
<Label Text="{Binding HarvestDate}" FontSize="Micro" TextColor="Black"/>
</StackLayout>
<Label Text="{Binding Location}" FontSize="Micro" TextColor="Chocolate" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
编辑:该错误似乎与我在CropListPage 中的ListView 有关,因为当我切换到Search icon 页面时没有错误。
【问题讨论】:
-
我认为导航页面应该包裹标签页,而不是标签页内的内容页。
-
@SteveChadbourne 如果我尝试,结果相同。但是我遵循了文档,并且做得对。它也可以包裹导航页面
-
@SteveChadbourne 检查它developer.xamarin.com/guides/xamarin-forms/…
-
是的,你是对的。事实上,它明确表示不要将点击的页面包装在导航页面中!
标签: xaml xamarin.forms navigation