diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml new file mode 100644 index 000000000..9cc28f6ac --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml.cs new file mode 100644 index 000000000..4197ffa91 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue4360.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; +using Xamarin.Forms.Xaml; + +namespace Xamarin.Forms.Controls.Issues +{ +#if APP + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 4360, "UWP: TapGestureRecognizer works on Layout only if BackgroundColor is set", + PlatformAffected.UWP)] + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class Issue4360 : ContentPage + { + const string Success = "Success"; + + public Issue4360() + { + + InitializeComponent(); + } + + void TapGestureRecognizer_OnTapped(object sender, EventArgs e) + { + Label.Text = Success; + } + + } +#endif +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 54d82daf0..3aa679ffa 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -412,6 +412,10 @@ + + Issue4360.xaml + Code + @@ -1058,4 +1062,10 @@ MSBuild:Compile - + + + Designer + MSBuild:Compile + + + \ No newline at end of file diff --git a/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs b/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs index e6ad73062..5d5e8c393 100644 --- a/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs @@ -617,6 +617,19 @@ namespace Xamarin.Forms.Platform.UWP { RemoveBackgroundLayer(); IsHitTestVisible = Element.IsEnabled && !Element.InputTransparent; + + if (!IsHitTestVisible) + { + return; + } + + // If this Panel's background brush is null, the UWP considers it transparent to hit testing (even + // when IsHitTestVisible is true). So we have to explicitly set a background brush to make it show up + // in hit testing. + if (Element is Layout && Background == null) + { + Background = new SolidColorBrush(Windows.UI.Colors.Transparent); + } } }