TapGestureRecognizer无法在Grid Row上运行

时间:2017-10-23 13:35:14

标签: xamarin xamarin.forms xamarin.android

我提出了以下布局。

enter image description here

在黄色区域,它将被保留用于选项和用户数据栏。红色区域将保留给listView和一些选项。

问题在于,当您按以下方式放置布局时:

<Grid 
   Grid.Row="1"
   Padding="0" 
   HorizontalOptions="FillAndExpand"
   VerticalOptions="FillAndExpand"
  IsVisible="{ Binding ErrorOccurred , Converter = { StaticResource InverseBoolConverter }  }">

    <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <Grid Grid.Row="0" HeightRequest="250" BackgroundColor="Yellow"></Grid>

      <StackLayout 
             x:Name="Body"
             Grid.Row="1"
             BackgroundColor="Red"
             HorizontalOptions="FillAndExpand"
             VerticalOptions="EndAndExpand"
             Padding="0"
            Spacing="0">
     </StackLayout>
</Grid>

我在Red StackLayout中放置的ListView和TapGestureRecognizer的滚动。它们不起作用。相反,我使用StackLayout而不是Grid。一切正常。但我不能让红色的StackLayout占用剩下的所有空间。

有人知道我可能做错了吗?

这是完整的页面代码。

<ContentPage.Content>
        <!-- MAIN CONTAINER -->
        <Grid RowSpacing="0">

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!-- APP Header -->
            <common:AppHeader 
                Grid.Row="0"
                Title="{i18n:Translate Page.Home.Title}"
                BackEnable="false">
                <common:AppHeader.Options>
                    <x:Array Type="{x:Type View}">
                        <common:RefreshOptionMenu />
                        <common:SettingsOptionMenu />
                        <common:SignOutOptionMenu />
                    </x:Array>
                </common:AppHeader.Options>

            </common:AppHeader>
            <!-- End APP Header -->

            <!--GRID WRAPPER-->
            <Grid 
                 Grid.Row="1"
                 Padding="0" 
                 IsVisible="{ Binding ErrorOccurred , Converter = { StaticResource InverseBoolConverter }  }">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <!-- PROFILE HEADER-->
                    <Grid 
                        Grid.Row="0"
                        HeightRequest="250"
                        Padding="0">

                        <!-- BACKGROUND IMAGE -->
                        <Image 
                            Source="{ StaticResource HomeBackground }"
                            IsOpaque="false"
                            Aspect="AspectFill"
                            HorizontalOptions="FillAndExpand"
                            VerticalOptions="FillAndExpand"/>

                        <StackLayout

                            HorizontalOptions="FillAndExpand" 
                            VerticalOptions="StartAndExpand"
                            Orientation="Vertical"
                            Spacing="20">

                            <Grid 
                                HorizontalOptions="Center"
                                VerticalOptions="Center"
                                TranslationY="25">

                                <!-- AVATAR -->
                                <ffimageloading:CachedImage
                                    x:Name="profileImage"
                                    CacheType="Disk"
                                    CacheDuration="30"
                                    WidthRequest="100"
                                    HeightRequest="100"
                                    FadeAnimationEnabled="true"
                                    ErrorPlaceholder="{ StaticResource ProfileErrorImage }"
                                    LoadingPlaceholder="{ StaticResource ProfileImagePlaceholder }"
                                    Source="{ Binding SelfParent.ProfileImage , Converter={ StaticResource ParentProfileImageURLConverter } }">
                                    <ffimageloading:CachedImage.Transformations>
                                         <fftransformations:CircleTransformation BorderSize="5" BorderHexColor="#FFFFFF" />
                                    </ffimageloading:CachedImage.Transformations>
                                 </ffimageloading:CachedImage>

                                  <!-- BADGE -->
                                  <common:Badge
                                    IsVisible="{ Binding  AlertsPage.Remaining, Converter={ StaticResource ValueGreaterThanZeroConverter }}"
                                    BadgeText="{ Binding  AlertsPage.Remaining, StringFormat='+ {0}'}"
                                    BadgeTextColor="{ DynamicResource InverseTextColor }"
                                    BadgeBackgroundColor="#22c064"
                                    HorizontalOptions="Center"
                                    VerticalOptions="Start"
                                    TranslationX="40">

                                    <common:Badge.GestureRecognizers>
                                        <TapGestureRecognizer Command="{ Binding GoToAlertsCommand }" NumberOfTapsRequired="1" /> 
                                    </common:Badge.GestureRecognizers>

                                </common:Badge>

                                <Grid.GestureRecognizers>
                                    <TapGestureRecognizer Command="{ Binding TakePhotoCommand }"  NumberOfTapsRequired="1" />
                                </Grid.GestureRecognizers>
                            </Grid>

                            <!-- Parent FullName -->
                            <StackLayout
                                Orientation="Horizontal"
                                HorizontalOptions="CenterAndExpand"
                                Padding="20">

                                <Label 
                                    HorizontalOptions="CenterAndExpand"
                                    Text="{Binding SelfParent.FullName}"
                                    TextColor="{ DynamicResource OverImageTextColor }"
                                    HorizontalTextAlignment="Center"
                                    FontAttributes="Bold"
                                    FontSize="{ artina:OnOrientationDouble
                                        PortraitPhone=22,
                                        LandscapePhone=22,
                                        PortraitTablet=24,
                                        LandscapeTablet=24 }"  />
                            </StackLayout>
                        </StackLayout>

                        <!-- TOOLBAR -->
                        <Grid
                            x:Name="MenuGrid"
                            VerticalOptions="End"
                            Style="{ StaticResource ToolbarStyle }"
                            BackgroundColor="{ DynamicResource TranslucidWhite }">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>


                            <!-- Children Action -->
                            <StackLayout
                                Grid.Column="0"
                                Orientation="Horizontal"
                                VerticalOptions="CenterAndExpand"
                                HorizontalOptions="Center"
                                Spacing="0">

                                <Label
                                    VerticalTextAlignment="Center"
                                    HorizontalTextAlignment="Center"
                                    Text="{ x:Static helper:FontAwesomeFont.Users }"
                                    FontFamily="{ StaticResource IconsFontFamily }"
                                    TextColor="{ DynamicResource InverseTextColor }">

                                    <Label.FontSize>
                                        <OnIdiom 
                                            x:TypeArguments="x:Double" 
                                            Phone="15" 
                                            Tablet="20" />
                                    </Label.FontSize>
                                </Label>

                                <Label
                                    VerticalTextAlignment="Center"
                                    HorizontalTextAlignment="Center"
                                    Text="{Binding SelfParent.Children, StringFormat={i18n:Translate Home.Toolbar.Children} }"
                                    TextColor="{ DynamicResource OverImageTextColor }">
                                    <Label.FontSize>
                                        <OnIdiom 
                                            x:TypeArguments="x:Double" 
                                            Phone="15" 
                                            Tablet="20" />
                                    </Label.FontSize> 
                                </Label>

                                <StackLayout.GestureRecognizers>
                                    <TapGestureRecognizer Command="{ Binding GoToChildrenCommand }" NumberOfTapsRequired="1" /> 
                                </StackLayout.GestureRecognizers>
                             </StackLayout>

                               <!-- IsEnabled="{ Binding SelfParent.Children, Converter={ StaticResource ValueGreaterThanZeroConverter }}" -->
                              <!-- Results Action -->
                              <StackLayout
                                Grid.Column="1"
                                Orientation="Horizontal"
                                VerticalOptions="CenterAndExpand"
                                HorizontalOptions="Center"
                                Spacing="0">

                                    <Label
                                        VerticalTextAlignment="Center"
                                        HorizontalTextAlignment="Center"
                                        Text="{ x:Static helper:FontAwesomeFont.AreaChart }"
                                        FontFamily="{ StaticResource IconsFontFamily }"
                                        TextColor="{ DynamicResource InverseTextColor }">
                                        <Label.FontSize>
                                            <OnIdiom 
                                                x:TypeArguments="x:Double" 
                                                Phone="15" 
                                                Tablet="20" />
                                         </Label.FontSize> 
                                     </Label>

                                      <Label
                                        VerticalTextAlignment="Center" 
                                        HorizontalTextAlignment="Center"
                                        Text="{i18n:Translate Home.Toolbar.Results}"
                                        TextColor="{ DynamicResource OverImageTextColor }">

                                        <Label.FontSize>
                                            <OnIdiom 
                                                x:TypeArguments="x:Double" 
                                                Phone="15"
                                                Tablet="20" />
                                         </Label.FontSize> 
                                    </Label>

                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer Command="{ Binding GoToResultsCommand}" NumberOfTapsRequired="1" /> 
                                    </StackLayout.GestureRecognizers>
                            </StackLayout>

                            <!-- Profile Action -->
                            <StackLayout
                                Grid.Column="2"
                                Orientation="Horizontal"
                                VerticalOptions="CenterAndExpand"
                                HorizontalOptions="Center"
                                Spacing="0">

                                    <Label
                                        VerticalTextAlignment="Center" 
                                        HorizontalTextAlignment="Center"
                                        Text="{ x:Static helper:FontAwesomeFont.User }"
                                        FontFamily="{ StaticResource IconsFontFamily }"
                                        TextColor="{ DynamicResource InverseTextColor }">
                                        <Label.FontSize>
                                            <OnIdiom 
                                                x:TypeArguments="x:Double" 
                                                Phone="15" 
                                                Tablet="20" />
                                        </Label.FontSize> 
                                    </Label>

                                    <Label
                                        VerticalTextAlignment="Center" 
                                        HorizontalTextAlignment="Center"
                                        Text="{i18n:Translate Home.Toolbar.Profile}"
                                        TextColor="{ DynamicResource OverImageTextColor }">
                                        <Label.FontSize>
                                            <OnIdiom 
                                                x:TypeArguments="x:Double" 
                                                Phone="15" 
                                                Tablet="20" />
                                        </Label.FontSize> 
                                    </Label>

                                    <StackLayout.GestureRecognizers>
                                        <TapGestureRecognizer Command="{ Binding GoToProfileCommand }" NumberOfTapsRequired="1" /> 
                                    </StackLayout.GestureRecognizers>
                               </StackLayout>
                            </Grid>
                        </Grid>
                        <!-- END PROFILE HEADER-->

                       <StackLayout 
                                x:Name="Body"
                                BackgroundColor="White"
                                Grid.Row="1"
                                HorizontalOptions="FillAndExpand"
                                VerticalOptions="StartAndExpand"
                                Padding="0">

                                <StackLayout
                                    Orientation="Horizontal">

                                    <StackLayout  
                                        Orientation="Horizontal"
                                        HorizontalOptions="StartAndExpand">

                                        <Label
                                            FontSize="18"
                                            Style="{ StaticResource CommonHeaderStyle }"
                                            Text="{ x:Static helper:FontAwesomeFont.Inbox }"
                                            FontFamily="{ StaticResource IconsFontFamily }" />

                                        <Label
                                            Style="{ StaticResource CommonHeaderStyle }"
                                            Text="{ Binding ListAlertTitle }"/>
                                    </StackLayout>

                                    <StackLayout
                                        Orientation="Horizontal"
                                        HorizontalOptions="End">

                                        <Label
                                            FontSize="14"
                                            HeightRequest="46"
                                            VerticalTextAlignment="Center"
                                            Text="{ i18n:Translate Home.Show.Alerts }"/>

                                        <Label
                                            Text="{ x:Static helper:FontAwesomeFont.ArrowRight }"
                                            VerticalTextAlignment="Center"
                                            Margin="5,0,5,0"
                                            FontFamily="{ StaticResource IconsFontFamily }" />

                                            <StackLayout.GestureRecognizers>
                                                <TapGestureRecognizer Command="{ Binding GoToAlertsCommand }" NumberOfTapsRequired="1" /> 
                                            </StackLayout.GestureRecognizers>
                                    </StackLayout>
                                </StackLayout>

                                <!-- Last Alerts LIST -->
                                <ListView
                                    x:Name="AlertsListView"
                                    ItemsSource="{Binding AlertsPage.Alerts}"
                                    RowHeight="90">

                                    <ListView.Behaviors>
                                        <utils:EventToCommandBehavior 
                                            EventName="ItemTapped"
                                            Command="{Binding ShowAlertDetailCommand}"
                                            EventArgsConverter="{ StaticResource ItemTappedEventArgsConverter }" />
                                    </ListView.Behaviors>

                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <commonControls:SearchPageViewCellWithId 
                                                FirstApper="SearchPageViewCellWithId_OnFirstApper"
                                                FirstDisapp="SearchPageViewCellWithId_OnFirstDisapp" 
                                                ItemId="{ Binding .,
                                                    Converter = { StaticResource ItemToIndexConverter }, 
                                                    ConverterParameter = { x:Reference AlertsListView } }">
                                                <templates:AlertItemTemplate/>
                                            </commonControls:SearchPageViewCellWithId>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>

                                <StackLayout.Triggers>
                                    <DataTrigger 
                                        TargetType="StackLayout"
                                        Binding="{Binding AlertsPage.Returned, Converter={ StaticResource ValueEqualToZeroConverter } }"
                                        Value="True">
                                        <Setter Property="IsVisible" Value="False" />
                                    </DataTrigger>
                                    <DataTrigger
                                       TargetType="StackLayout"
                                        Binding="{Binding IsBusy}"
                                        Value="True">
                                        <Setter Property="IsVisible" Value="False" />
                                    </DataTrigger>
                                </StackLayout.Triggers>
                            </StackLayout>

                            <templates:NoChildrenFound
                                Grid.Row="1"
                                IsVisible="{ Binding ShouldShowNoChildrenFound}"
                                VerticalOptions="CenterAndExpand"
                                Padding="20" />

                            <common:ActivityLoading
                                Grid.Row="1"
                                Icon="{ x:Static helper:FontAwesomeFont.Bell }"
                                IsLoading="{ Binding IsBusy }"
                                LoadingText="{i18n:Translate Common.Loading}"/>

                             <!-- No Alerts Found -->
                            <common:NoDataFound 
                                Grid.Row="1"
                                IsVisible="{ Binding ShouldShowNoAlertsFound }"
                                MainText="{i18n:Translate Home.Alerts.Not.Found.MainText }"
                                DetailText="{i18n:Translate Home.Alerts.Not.Found.SecondText }">
                            </common:NoDataFound>
                </Grid>
                <!-- END GRID WRAPPER--> 

                <common:ErrorOcurred 
                    Grid.Row="1"
                    IsVisible="{ Binding ErrorOccurred }"
                    MainText="{i18n:Translate Home.Profile.Load.Error}"/>


           </Grid>
           <!-- END MAIN CONTAINER -->
    </ContentPage.Content>

提前致谢。

1 个答案:

答案 0 :(得分:1)

尝试将您的XAML代码更改为此(您需要测试,我无法在此处执行):

<ContentPage.Content>
    <!-- MAIN CONTAINER -->
    <Grid RowSpacing="0">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- APP Header -->
        <common:AppHeader 
            Grid.Row="0"
            Title="{i18n:Translate Page.Home.Title}"
            BackEnable="false">
            <common:AppHeader.Options>
                <x:Array Type="{x:Type View}">
                    <common:RefreshOptionMenu />
                    <common:SettingsOptionMenu />
                    <common:SignOutOptionMenu />
                </x:Array>
            </common:AppHeader.Options>

        </common:AppHeader>
        <!-- End APP Header -->

        <!--GRID WRAPPER-->
        <Grid 
             Grid.Row="1"
             Padding="0" 
             IsVisible="{ Binding ErrorOccurred , Converter = { StaticResource InverseBoolConverter }  }">

            <Grid.RowDefinitions>
                <RowDefinition Height="250" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <!-- PROFILE HEADER-->
            <Grid 
                Grid.Row="0"
                Padding="0">

                <!-- BACKGROUND IMAGE -->
                <Image 
                    Source="{ StaticResource HomeBackground }"
                    IsOpaque="false"
                    Aspect="AspectFill"
                    HorizontalOptions="FillAndExpand"
                    VerticalOptions="FillAndExpand"/>

                <StackLayout

                    HorizontalOptions="FillAndExpand" 
                    VerticalOptions="StartAndExpand"
                    Orientation="Vertical"
                    Spacing="20">

                    <Grid 
                        HorizontalOptions="Center"
                        VerticalOptions="Center"
                        TranslationY="25">

                        <!-- AVATAR -->
                        <ffimageloading:CachedImage
                            x:Name="profileImage"
                            CacheType="Disk"
                            CacheDuration="30"
                            WidthRequest="100"
                            HeightRequest="100"
                            FadeAnimationEnabled="true"
                            ErrorPlaceholder="{ StaticResource ProfileErrorImage }"
                            LoadingPlaceholder="{ StaticResource ProfileImagePlaceholder }"
                            Source="{ Binding SelfParent.ProfileImage , Converter={ StaticResource ParentProfileImageURLConverter } }">
                            <ffimageloading:CachedImage.Transformations>
                                 <fftransformations:CircleTransformation BorderSize="5" BorderHexColor="#FFFFFF" />
                            </ffimageloading:CachedImage.Transformations>
                         </ffimageloading:CachedImage>

                          <!-- BADGE -->
                          <common:Badge
                            IsVisible="{ Binding  AlertsPage.Remaining, Converter={ StaticResource ValueGreaterThanZeroConverter }}"
                            BadgeText="{ Binding  AlertsPage.Remaining, StringFormat='+ {0}'}"
                            BadgeTextColor="{ DynamicResource InverseTextColor }"
                            BadgeBackgroundColor="#22c064"
                            HorizontalOptions="Center"
                            VerticalOptions="Start"
                            TranslationX="40">

                            <common:Badge.GestureRecognizers>
                                <TapGestureRecognizer Command="{ Binding GoToAlertsCommand }" NumberOfTapsRequired="1" /> 
                            </common:Badge.GestureRecognizers>

                        </common:Badge>

                        <Grid.GestureRecognizers>
                            <TapGestureRecognizer Command="{ Binding TakePhotoCommand }"  NumberOfTapsRequired="1" />
                        </Grid.GestureRecognizers>
                    </Grid>

                    <!-- Parent FullName -->
                    <StackLayout
                        Orientation="Horizontal"
                        HorizontalOptions="CenterAndExpand"
                        Padding="20">

                        <Label 
                            HorizontalOptions="CenterAndExpand"
                            Text="{Binding SelfParent.FullName}"
                            TextColor="{ DynamicResource OverImageTextColor }"
                            HorizontalTextAlignment="Center"
                            FontAttributes="Bold"
                            FontSize="{ artina:OnOrientationDouble
                                PortraitPhone=22,
                                LandscapePhone=22,
                                PortraitTablet=24,
                                LandscapeTablet=24 }"  />
                    </StackLayout>
                </StackLayout>

                <!-- TOOLBAR -->
                <Grid
                    x:Name="MenuGrid"
                    VerticalOptions="End"
                    Style="{ StaticResource ToolbarStyle }"
                    BackgroundColor="{ DynamicResource TranslucidWhite }">

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>


                    <!-- Children Action -->
                    <StackLayout
                        Grid.Column="0"
                        Orientation="Horizontal"
                        VerticalOptions="CenterAndExpand"
                        HorizontalOptions="Center"
                        Spacing="0">

                        <Label
                            VerticalTextAlignment="Center"
                            HorizontalTextAlignment="Center"
                            Text="{ x:Static helper:FontAwesomeFont.Users }"
                            FontFamily="{ StaticResource IconsFontFamily }"
                            TextColor="{ DynamicResource InverseTextColor }">

                            <Label.FontSize>
                                <OnIdiom 
                                    x:TypeArguments="x:Double" 
                                    Phone="15" 
                                    Tablet="20" />
                            </Label.FontSize>
                        </Label>

                        <Label
                            VerticalTextAlignment="Center"
                            HorizontalTextAlignment="Center"
                            Text="{Binding SelfParent.Children, StringFormat={i18n:Translate Home.Toolbar.Children} }"
                            TextColor="{ DynamicResource OverImageTextColor }">
                            <Label.FontSize>
                                <OnIdiom 
                                    x:TypeArguments="x:Double" 
                                    Phone="15" 
                                    Tablet="20" />
                            </Label.FontSize> 
                        </Label>

                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Command="{ Binding GoToChildrenCommand }" NumberOfTapsRequired="1" /> 
                        </StackLayout.GestureRecognizers>
                     </StackLayout>

                       <!-- IsEnabled="{ Binding SelfParent.Children, Converter={ StaticResource ValueGreaterThanZeroConverter }}" -->
                      <!-- Results Action -->
                      <StackLayout
                        Grid.Column="1"
                        Orientation="Horizontal"
                        VerticalOptions="CenterAndExpand"
                        HorizontalOptions="Center"
                        Spacing="0">

                            <Label
                                VerticalTextAlignment="Center"
                                HorizontalTextAlignment="Center"
                                Text="{ x:Static helper:FontAwesomeFont.AreaChart }"
                                FontFamily="{ StaticResource IconsFontFamily }"
                                TextColor="{ DynamicResource InverseTextColor }">
                                <Label.FontSize>
                                    <OnIdiom 
                                        x:TypeArguments="x:Double" 
                                        Phone="15" 
                                        Tablet="20" />
                                 </Label.FontSize> 
                             </Label>

                              <Label
                                VerticalTextAlignment="Center" 
                                HorizontalTextAlignment="Center"
                                Text="{i18n:Translate Home.Toolbar.Results}"
                                TextColor="{ DynamicResource OverImageTextColor }">

                                <Label.FontSize>
                                    <OnIdiom 
                                        x:TypeArguments="x:Double" 
                                        Phone="15"
                                        Tablet="20" />
                                 </Label.FontSize> 
                            </Label>

                            <StackLayout.GestureRecognizers>
                                <TapGestureRecognizer Command="{ Binding GoToResultsCommand}" NumberOfTapsRequired="1" /> 
                            </StackLayout.GestureRecognizers>
                    </StackLayout>

                    <!-- Profile Action -->
                    <StackLayout
                        Grid.Column="2"
                        Orientation="Horizontal"
                        VerticalOptions="CenterAndExpand"
                        HorizontalOptions="Center"
                        Spacing="0">

                            <Label
                                VerticalTextAlignment="Center" 
                                HorizontalTextAlignment="Center"
                                Text="{ x:Static helper:FontAwesomeFont.User }"
                                FontFamily="{ StaticResource IconsFontFamily }"
                                TextColor="{ DynamicResource InverseTextColor }">
                                <Label.FontSize>
                                    <OnIdiom 
                                        x:TypeArguments="x:Double" 
                                        Phone="15" 
                                        Tablet="20" />
                                </Label.FontSize> 
                            </Label>

                            <Label
                                VerticalTextAlignment="Center" 
                                HorizontalTextAlignment="Center"
                                Text="{i18n:Translate Home.Toolbar.Profile}"
                                TextColor="{ DynamicResource OverImageTextColor }">
                                <Label.FontSize>
                                    <OnIdiom 
                                        x:TypeArguments="x:Double" 
                                        Phone="15" 
                                        Tablet="20" />
                                </Label.FontSize> 
                            </Label>

                            <StackLayout.GestureRecognizers>
                                <TapGestureRecognizer Command="{ Binding GoToProfileCommand }" NumberOfTapsRequired="1" /> 
                            </StackLayout.GestureRecognizers>
                       </StackLayout>
                    </Grid>
                </Grid>
                <!-- END PROFILE HEADER-->

           <StackLayout 
                    x:Name="Body"
                    BackgroundColor="White"
                    Grid.Row="1"
                    HorizontalOptions="FillAndExpand"
                    VerticalOptions="StartAndExpand"
                    Padding="0">

                    <StackLayout
                        Orientation="Horizontal">

                        <StackLayout  
                            Orientation="Horizontal"
                            HorizontalOptions="StartAndExpand">

                            <Label
                                FontSize="18"
                                Style="{ StaticResource CommonHeaderStyle }"
                                Text="{ x:Static helper:FontAwesomeFont.Inbox }"
                                FontFamily="{ StaticResource IconsFontFamily }" />

                            <Label
                                Style="{ StaticResource CommonHeaderStyle }"
                                Text="{ Binding ListAlertTitle }"/>
                        </StackLayout>

                        <StackLayout
                            Orientation="Horizontal"
                            HorizontalOptions="End">

                            <Label
                                FontSize="14"
                                HeightRequest="46"
                                VerticalTextAlignment="Center"
                                Text="{ i18n:Translate Home.Show.Alerts }"/>

                            <Label
                                Text="{ x:Static helper:FontAwesomeFont.ArrowRight }"
                                VerticalTextAlignment="Center"
                                Margin="5,0,5,0"
                                FontFamily="{ StaticResource IconsFontFamily }" />

                                <StackLayout.GestureRecognizers>
                                    <TapGestureRecognizer Command="{ Binding GoToAlertsCommand }" NumberOfTapsRequired="1" /> 
                                </StackLayout.GestureRecognizers>
                        </StackLayout>
                    </StackLayout>

                    <!-- Last Alerts LIST -->
                    <ListView
                        x:Name="AlertsListView"
                        ItemsSource="{Binding AlertsPage.Alerts}"
                        VerticalOptions="FillAndExpand"
                        RowHeight="90">

                        <ListView.Behaviors>
                            <utils:EventToCommandBehavior 
                                EventName="ItemTapped"
                                Command="{Binding ShowAlertDetailCommand}"
                                EventArgsConverter="{ StaticResource ItemTappedEventArgsConverter }" />
                        </ListView.Behaviors>

                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <commonControls:SearchPageViewCellWithId 
                                    FirstApper="SearchPageViewCellWithId_OnFirstApper"
                                    FirstDisapp="SearchPageViewCellWithId_OnFirstDisapp" 
                                    ItemId="{ Binding .,
                                        Converter = { StaticResource ItemToIndexConverter }, 
                                        ConverterParameter = { x:Reference AlertsListView } }">
                                    <templates:AlertItemTemplate/>
                                </commonControls:SearchPageViewCellWithId>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

                    <StackLayout.Triggers>
                        <DataTrigger 
                            TargetType="StackLayout"
                            Binding="{Binding AlertsPage.Returned, Converter={ StaticResource ValueEqualToZeroConverter } }"
                            Value="True">
                            <Setter Property="IsVisible" Value="False" />
                        </DataTrigger>
                        <DataTrigger
                           TargetType="StackLayout"
                            Binding="{Binding IsBusy}"
                            Value="True">
                            <Setter Property="IsVisible" Value="False" />
                        </DataTrigger>
                    </StackLayout.Triggers>
                </StackLayout>

                <templates:NoChildrenFound
                    Grid.Row="1"
                    IsVisible="{ Binding ShouldShowNoChildrenFound}"
                    VerticalOptions="CenterAndExpand"
                    Padding="20" />

                <common:ActivityLoading
                    Grid.Row="1"
                    Icon="{ x:Static helper:FontAwesomeFont.Bell }"
                    IsLoading="{ Binding IsBusy }"
                    LoadingText="{i18n:Translate Common.Loading}"/>

                 <!-- No Alerts Found -->
                <common:NoDataFound 
                    Grid.Row="1"
                    IsVisible="{ Binding ShouldShowNoAlertsFound }"
                    MainText="{i18n:Translate Home.Alerts.Not.Found.MainText }"
                    DetailText="{i18n:Translate Home.Alerts.Not.Found.SecondText }">
                </common:NoDataFound>
            </Grid>
            <!-- END GRID WRAPPER--> 

            <common:ErrorOcurred 
                Grid.Row="1"
                IsVisible="{ Binding ErrorOccurred }"
                MainText="{i18n:Translate Home.Profile.Load.Error}"/>


       </Grid>
       <!-- END MAIN CONTAINER -->
</ContentPage.Content>

但如果您不介意,我会给您一个建议:根据您的需要选择正确的布局。除了性能,你将摆脱不必要的代码。有关详细信息,请参阅this article

我希望它可以帮到你。