【问题标题】:NavigationPage Wrapping causing bug in status barNavigationPage Wrapping 导致状态栏中的错误
【发布时间】: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 如果我尝试,结果相同。但是我遵循了文档,并且做得对。它也可以包裹导航页面
  • 是的,你是对的。事实上,它明确表示不要将点击的页面包装在导航页面中!

标签: xaml xamarin.forms navigation


【解决方案1】:

第一张图片中的额外空间是NavigationPage 默认显示导航栏的结果,该导航栏可以隐藏。

Here's 一个如何隐藏它的示例。

【讨论】:

    【解决方案2】:

    可能是因为您在导航页面中已包装裁剪列表页面,因此选择该播放页面时,您将获得上面的NAV栏空间。

    如果选择第二个选项卡,空格会消失吗?

    如果给裁剪页面添加标题,它会出现在大的绿色空间中吗?

    <?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:Chronocrops.Views"
           x:Class="Chronocrops.Views.MainPage">
    
       <NavigationPage Icon="carrot.png" Title="Crop List">
        <x:Arguments>
            <local:CropListPage/>
        </x:Arguments>
       </NavigationPage> 
       <ContentPage Icon="search.png"></ContentPage>
    
     </TabbedPage>
    

    【讨论】:

    • 是的,你是对的,在Search icon page 中它保持正常。不,Title 仍然在里面。我会上传一张图片。关于为什么会发生这种情况的任何想法只是因为我在页面中有一个ListView
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    相关资源
    最近更新 更多