Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd5e0c9
Allow gestures in Windows ContentView
jsuarezruiz Sep 18, 2023
edfddf1
Merge branch 'main' into fix-15810
jsuarezruiz Sep 21, 2023
846c219
Merge branch 'main' into fix-15810
jsuarezruiz Sep 27, 2023
06ea549
Merge branch 'main' into fix-15810
jsuarezruiz Oct 4, 2023
43b6e65
Merge branch 'main' into fix-15810
jsuarezruiz Oct 18, 2023
c755c81
Updated the test
jsuarezruiz Oct 18, 2023
c8dd152
Merge branch 'main' into fix-15810
jsuarezruiz Oct 18, 2023
32642bc
Merge branch 'main' into fix-15810
jsuarezruiz Oct 20, 2023
d651556
Merge branch 'main' into fix-15810
jsuarezruiz Oct 25, 2023
131c86c
Merge branch 'main' into fix-15810
jsuarezruiz Nov 2, 2023
13dba02
Updated test
jsuarezruiz Nov 3, 2023
de078a4
Merge branch 'main' into fix-15810
jsuarezruiz Nov 9, 2023
8601141
Changes in the test
jsuarezruiz Nov 9, 2023
db61f63
Merge branch 'main' into fix-15810
jsuarezruiz Dec 12, 2023
967eb9d
Merge branch 'main' into fix-15810
jsuarezruiz Jan 22, 2024
c18468a
Merge branch 'main' into fix-15810
jsuarezruiz Feb 8, 2024
f808172
Merge branch 'main' into fix-15810
jsuarezruiz Feb 27, 2024
310ab57
Merge branch 'main' into fix-15810
jsuarezruiz Mar 5, 2024
a0bc339
Merge branch 'main' into fix-15810
jsuarezruiz Apr 11, 2024
b5fda99
Fixes the build
jsuarezruiz Apr 11, 2024
bed291f
Merge branch 'main' into fix-15810
jsuarezruiz Apr 25, 2024
77bc622
More fixes
jsuarezruiz Apr 25, 2024
baabcb8
Fix test snapshot
jsuarezruiz Apr 29, 2024
1244445
Merge branch 'main' into fix-15810
jsuarezruiz Apr 29, 2024
e15f4bb
Merge branch 'main' into fix-15810
jsuarezruiz May 16, 2024
54df71c
Moved test sample
jsuarezruiz May 17, 2024
6e1d53c
Merge branch 'main' into fix-15810
jsuarezruiz Feb 5, 2025
e7de33b
Merge branch 'main' into fix-15810
jsuarezruiz Mar 7, 2025
778db68
Remove duplicated line
jsuarezruiz Mar 7, 2025
af21399
Merge branch 'main' into fix-15810
jsuarezruiz Mar 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue15810.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 15810, "TapGestureRecognizer Tapped events not worked in Windows Platform", PlatformAffected.UWP)]
public class Issue15810 : TestContentPage
{
protected override void Init()
{
var grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

var customView = new CustomView
{
AutomationId = "CustomView"
};

var infoLabel = new Label
{
AutomationId = "InfoLabel"
};

Grid.SetRow(customView, 0);
grid.Children.Add(customView);

Grid.SetRow(infoLabel, 1);
grid.Children.Add(infoLabel);

customView.Tapped += (sender, args) =>
{
infoLabel.Text = "Tapped";
};

Content = grid;
}
}

internal class CustomView : ContentView
{
public CustomView()
{
var absoluteLayout = new AbsoluteLayout();
Content = absoluteLayout;

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += OnBoxTapped;
GestureRecognizers.Add(tapGestureRecognizer);
}

public EventHandler Tapped;

private void OnBoxTapped(object sender, EventArgs e)
{
BackgroundColor = BackgroundColor == Colors.Red ? Colors.Green : Colors.Red;
Tapped?.Invoke(this, EventArgs.Empty);
}
}
}
30 changes: 30 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue15810.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue15810 : _IssuesUITest
{
readonly string _customViewId = "CustomView";

public Issue15810(TestDevice device) : base(device)
{
}

public override string Issue => "TapGestureRecognizer Tapped events not worked in Windows Platform";

[Test]
public void WhenTapCustomViewThenChangesColor()
{
// FindElement is not able to get a ContentView on Windows
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Windows });

App.WaitForElement(_customViewId);
App.Click(_customViewId);

var infoText = App.FindElement("InfoLabel").GetText();
Assert.IsNotEmpty(infoText);
}
}
}
15 changes: 14 additions & 1 deletion src/Core/src/Handlers/ContentView/ContentViewHandler.Windows.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Handlers
{
Expand Down Expand Up @@ -37,7 +38,8 @@ protected override ContentPanel CreatePlatformView()

var view = new ContentPanel
{
CrossPlatformLayout = VirtualView
CrossPlatformLayout = VirtualView,
IsHitTestVisible = true
};

return view;
Expand All @@ -55,5 +57,16 @@ protected override void DisconnectHandler(ContentPanel platformView)

base.DisconnectHandler(platformView);
}

static UI.Xaml.FrameworkElement? CreateContent(IView content, IMauiContext mauiContext)
{
var platformContent = content.ToPlatform(mauiContext);

var defaultBrush = new UI.Xaml.Media.SolidColorBrush(Colors.Transparent.ToWindowsColor());
platformContent.UpdatePlatformViewBackground(content, defaultBrush);

return platformContent;

}
}
}
12 changes: 12 additions & 0 deletions src/Core/src/Platform/Windows/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ internal static void UpdatePlatformViewBackground(this FrameworkElement platform
panel.UpdateBackground(view.Background);
}

internal static void UpdatePlatformViewBackground(this FrameworkElement platformView, IView view, Brush? defaultBrush = null)
{
(platformView as ContentPanel)?.UpdateBackground(null);

if (platformView is Control control)
control.UpdateBackground(view.Background, defaultBrush);
else if (platformView is Border border)
border.UpdateBackground(view.Background, defaultBrush);
else if (platformView is Panel panel)
panel.UpdateBackground(view.Background, defaultBrush);
}

public static async Task UpdateBackgroundImageSourceAsync(this FrameworkElement platformView, IImageSource? imageSource, IImageSourceServiceProvider? provider)
{
if (platformView is Control control)
Expand Down
Loading