Skip to content

[Windows] TapGestureRecognizer does NOT work on a ContentView without Background #32279

Description

@albyrock87

Description

Adding a gesture recognizer on a ContentView on Windows platform does not work unless you set a background.
Works fine on iOS and Android.

Steps to Reproduce

Using MAUI UITest project in MauiProgram.user.cs

namespace Maui.Controls.Sample;

public partial class MauiProgram
{
	static partial void OverrideMainPage(ref Page mainPage)
	{
		var contentPage = new ContentPage();
		var grid = new Grid();
		var contentView = new ContentView();
		var tap = new TapGestureRecognizer();
		tap.Tapped += (s, e) =>
		{
			Console.WriteLine("Click");
		};
		contentView.GestureRecognizers.Add(tap);
		grid.Add(contentView);
		contentPage.Content = grid;

                // Uncommenting this makes the tap gesture recognizer work
		//contentView.Background = Colors.Red;

		mainPage = contentPage;
	}
}

Link to public reproduction project repository

No response

Version with bug

9.0.110 SR12

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

Setting a Colors.Transparent background, or use Grid instead of ContentView.

I believe Grid is working thanks to the InputTransparent mapper.

internal static void UpdatePlatformViewBackground(this LayoutPanel layoutPanel, ILayout layout)
{
layoutPanel.UpdateInputTransparent(layout.InputTransparent, layout?.Background?.ToPlatform());
}

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions