Xamarin表单:使用RelativeLayout覆盖在网格上时无法单击框架

时间:2017-10-09 04:03:49

标签: xamarin xamarin.forms

enter image description here

这就是我想要实现的目标。绿色斑点是一个按钮(或堆叠布局或框架)。我能够更改所选和未选定选项卡的颜色。但我只是无法实现这一点。任何帮助将不胜感激。

更新 我扔掉了TabbedPage并使用框架和网格实现了标签。我现在正在使用RelativeLayout来获取Grid上的按钮。 Xaml位于

之下
   <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <Grid
            Margin="0"
            Padding="0"
            ColumnSpacing="0"
            HorizontalOptions="FillAndExpand"
            IsClippedToBounds="False"
            RowSpacing="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="70" />
            </Grid.RowDefinitions>
            <Frame
                x:Name="Explore"
                Grid.Row="0"
                Grid.Column="0"
                AutomationId="Explore"
                BackgroundColor="{Binding BgColorExplore}"
                ClassId="Explore"
                OutlineColor="Transparent">
                <Frame.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding TapTabCommand}" CommandParameter="{x:Reference Explore}" />
                </Frame.GestureRecognizers>
                <StackLayout
                    HorizontalOptions="FillAndExpand"
                    Style="{StaticResource NoSpaceStack}"
                    VerticalOptions="FillAndExpand">
                    <Image
                        HeightRequest="29"
                        HorizontalOptions="CenterAndExpand"
                        Source="exploreiconwhite.png"
                        VerticalOptions="Start"
                        WidthRequest="30" />
                    <customRenderers:ExtendedLabel
                        HorizontalTextAlignment="Center"
                        Style="{StaticResource TabbedTitle}"
                        Text="Explore" />
                </StackLayout>
            </Frame>
            <Frame
                x:Name="MyAccount"
                Grid.Row="0"
                Grid.Column="1"
                AutomationId="MyAccount"
                BackgroundColor="{Binding BgColorMyAccount}"
                ClassId="MyAccount"
                OutlineColor="Transparent">
                <Frame.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding TapTabCommand}" CommandParameter="{x:Reference MyAccount}" />
                </Frame.GestureRecognizers>
                <StackLayout
                    HorizontalOptions="FillAndExpand"
                    Style="{StaticResource NoSpaceStack}"
                    VerticalOptions="FillAndExpand">
                    <Image
                        HeightRequest="27"
                        HorizontalOptions="CenterAndExpand"
                        Source="Myaccounticonwhite.png"
                        VerticalOptions="Start"
                        WidthRequest="30" />
                    <customRenderers:ExtendedLabel
                        HorizontalTextAlignment="Center"
                        Style="{StaticResource TabbedTitle}"
                        Text="My Account" />
                </StackLayout>
            </Frame>
        </Grid>
        <RelativeLayout BackgroundColor="Yellow" HorizontalOptions="Center">
            <Frame
                BorderRadius="50"
                HeightRequest="67"
                HorizontalOptions="Center"
                OutlineColor="Transparent"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
                                                                  Property=Y,
                                                                  Constant=-140}"
                WidthRequest="67">
                <Frame.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding CreatePlanCommand}" />
                </Frame.GestureRecognizers>
                <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                    <Image
                        HeightRequest="32"
                        Source="createplaniconwhite.png"
                        WidthRequest="39" />
                    <Label
                        FontFamily="{StaticResource SofiaProSemiBold}"
                        FontSize="10"
                        HorizontalTextAlignment="Center"
                        Text="Create Plan"
                        TextColor="White" />
                </StackLayout>
            </Frame>
        </RelativeLayout>
    </StackLayout>

但现在当我点击标签上方的部分框架时,标签的点击事件会触发:(...如何使GreenFrames点击事件触发?

0 个答案:

没有答案