Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Propagate touch from top view

$
0
0

Hello,
I have a grid in top of another grid. Both grids have views that should respond to tap gestures.
The problem is that the views that are in the grid "below" can't be touched.

I have tried to set "InputTransparent" to the Grid on top but then the views of the top grid can't be touched.

A simplified example:
XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Zungri.Itinerario">

    <Grid>
        <Grid x:Name="grid1" RowSpacing="0" ColumnSpacing="0">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="10" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="10" />
            </Grid.ColumnDefinitions>

            <BoxView x:Name="box1" Color="Red" Grid.Row="1" Grid.Column="1" />
        </Grid>
        <Grid x:Name="grid2" RowSpacing="0" ColumnSpacing="0" BackgroundColor="Transparent">
            <Grid.RowDefinitions>
              <RowDefinition Height="10" />
              <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="10" />
              <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <BoxView x:Name="box2" Color="Blue" Grid.Row="0" Grid.Column="0" />
        </Grid>
    </Grid>
</ContentPage>

cs file:

            var tapB1 = new TapGestureRecognizer();
            tapB1.Tapped += (s, e) =>
            {
                Navigation.PushAsync (new POIPage());
            };
            box1.GestureRecognizers.Add(tapB1);
            box2.GestureRecognizers.Add(tapB1);

in this example I can't touch "box1". If I add grid2.InputTransparent = true;then box2 is the one that can't be touched.

Anyone has a solution to this?


Viewing all articles
Browse latest Browse all 77050

Trending Articles