dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.95k stars 1.7k forks source link

multiple Grid DropGestureRecognizers under Android will receive the message! #20886

Open bestvcboy opened 6 months ago

bestvcboy commented 6 months ago

Description

Description

Only one of multiple DropGestureRecognizers under Android will receive the message.(.NET 8) Description If there are multiple DropGestureRecognizers under a ContentPage in Android, only one will receive the message.

MauiApp15.zip

Steps to Reproduce

附件

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Relevant log output

bestvcboy commented 6 months ago

https://github.com/dotnet/maui/assets/42270303/94286455-a79d-44bf-878a-edad8d94ca3f

bestvcboy commented 6 months ago

Using one GRID for three IMAGs will make everything normal. [Uploading MainPage.txt…]()

bestvcboy commented 6 months ago

https://github.com/dotnet/maui/assets/42270303/36e71207-d0ba-43d8-a6c9-f4413bf92cbb

drasticactions commented 6 months ago

I think your Grid layout is the root issue:

スクリーンショット 2024-02-28 18 24 15

You have a multiple Grids that are effectively at the same root level, with a drop target that's nested two deep. While it "works" there are better ways to represent this that require less nesting and would make more sense in a real application,

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp15.MainPage">

    <Grid RowDefinitions="33*, 33*, 33*">
        <Image
            Grid.Row="0"
            Source="dotnet_bot.png"
            HeightRequest="185"
            Aspect="AspectFit"
            SemanticProperties.Description="dot net bot in a race car number eight" >
            <Image.GestureRecognizers>
                <DragGestureRecognizer />
            </Image.GestureRecognizers>
        </Image>
        <Image
            Grid.Row="1"
            Source="dotnet_bot.png" x:Name="drop1"
            HeightRequest="185"
            Aspect="AspectFit"
            SemanticProperties.Description="dot net bot in a race car number eight" >
            <Image.GestureRecognizers>
                <DropGestureRecognizer DragOver="DropGestureRecognizer_DragOver" />
            </Image.GestureRecognizers>
        </Image>
        <Image x:Name="drop2"
               Grid.Row="2"
               Source="dotnet_bot.png"
               HeightRequest="185"
               Aspect="AspectFit"
               SemanticProperties.Description="dot net bot in a race car number eight" >
            <Image.GestureRecognizers>
                <DropGestureRecognizer DragOver="DropGestureRecognizer_DragOver_1" />
            </Image.GestureRecognizers>
        </Image>
    </Grid>
</ContentPage>
スクリーンショット 2024-02-28 18 42 11

It's not the multiple grids that are at issue here, it's that you're nesting them without setting the rows and columns, This causes them to be all at the "top level" of the visual tree, so it's not too surprising that one drop handle would override the other, since it can't be seen.

There may be a bug here with in MAUI with drop gestures are seen with the UI you wrote, but IMO I think there needs to be a more realistic case where you can hit this.

bestvcboy commented 6 months ago

This is just a simplified model of mine. Because I'm developing a kind of mini-game where each object is a component, and this component uses nested Grids for positioning on the screen. The positions also change, so I used multiple GRIDs for nesting, which is why it turned out this way.

kevinxufei commented 5 months ago

Verified this issue with Visual Studio 17.10.0 Preview 2. Can repro on Android platform with sample project.