0

In my XAML Page, I have nested stacklayouts, and in an end nest, I have two buttons. Only one of them will click (the first one). I have made it real simple. Only Color is different. When I put the red one on top, it will click. When I put the green one on top, it will click. Why both do not click, why only the first one? I need both to click.

        <StackLayout Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions= "CenterAndExpand" HeightRequest="75" IsVisible="{Binding IsUpcomingTrip}">
            <StackLayout Orientation="Vertical" HorizontalOptions= "CenterAndExpand">
                <StackLayout Orientation="Horizontal" VerticalOptions="Start" HorizontalOptions= "FillAndExpand" HeightRequest="25">
                </StackLayout>
                <Button x:Name="btnCancelTrip1" Text="CANCEL TRIP" TextColor="WhiteSmoke" BackgroundColor="Red"
                        HorizontalOptions="FillAndExpand" Clicked="Test_Click">
                </Button>
                <Button x:Name="btnUpcomingTrip" Text="  REGISTER YOUR UPCOMING TRIP  " TextColor="WhiteSmoke" BackgroundColor="DarkGreen"
                        HorizontalOptions="FillAndExpand" Clicked="Test_Click">
                </Button>
            </StackLayout>
        </StackLayout>

I expect that both buttons should be clickable. Only the first one is clickable. When red on top, it is enabled/ clickable. When green on top, it is enabled/clickable. But not both.

aa_wlf
  • 1
  • 1
  • I have tested that it works at single StackLayout nesting, and 2-layer nesting. So the problem happens when there are 3 layers of StackLayouts. I wonder if this is a bug. – aa_wlf Apr 09 '19 at 14:48

1 Answers1

0

The solution is to remove one stack layer. The buttons will work fine if there are two nested stack layers, but not when there are three (In which case only the first one works).

If you really need a 3rd layer, then use Grid for the 3rd layer instead of StackLayout.

aa_wlf
  • 1
  • 1