unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.09k stars 739 forks source link

[Desktop/Desktop WSL] Events Not Triggered When Using Image #18528

Closed agneszitte closed 3 weeks ago

agneszitte commented 1 month ago

Current behavior

When using Tapped, DoubleTapped, PointerPressed,... events on an Image, the event is not triggered on Desktop or Desktop WSL. However, the same events are working as expected on other controls such as Border for example.

Expected behavior

The Tapped, DoubleTapped, PointerPressed,... events should be triggered when interacting with an Image, similar to how they work with other UI elements like Border or to how they work for all the other platforms.

How to reproduce it (as minimally and precisely as possible)

Sample App to Repro: TappedEventIssue.zip

Create a new project with the following XAML and C# code:

<Grid>
  <StackPanel Spacing="10"
              HorizontalAlignment="Center"
              VerticalAlignment="Center">
    <TextBlock Text="Hello Uno Platform!"
               HorizontalAlignment="Center" />

    <Border Height="100"
            Width="100"
            Background="LightBlue"
            Tapped="Tapped_Event">
      <TextBlock Text="Tapped Test"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center" />
    </Border>

    <Image Height="100"
           Tapped="Tapped_Event"
           Source="ms-appx:///Assets/unologo.jpg" />

    <Border Height="100"
            Width="100"
            Background="LightPink"
            DoubleTapped="DoubleTapped_Event">
      <TextBlock Text="DoubleTapped Test"
                 HorizontalTextAlignment="Center"
                 TextWrapping="WrapWholeWords"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center" />
    </Border>

    <Image Height="100"
           DoubleTapped="DoubleTapped_Event"
           Source="ms-appx:///Assets/unologo.jpg" />

    <Border Height="100"
            Width="100"
            Background="LightGreen"
            PointerPressed="PointerPressed_Event">
      <TextBlock Text="PointerPressed Test"
                 HorizontalTextAlignment="Center"
                 TextWrapping="WrapWholeWords"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center" />
    </Border>

    <Image Height="100"
           PointerPressed="PointerPressed_Event"
           Source="ms-appx:///Assets/unologo.jpg" />
  </StackPanel>
</Grid>
private async void Tapped_Event(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
    ContentDialog dialog = new ContentDialog
    {
        Title = "Tapped Event",
        Content = "Tapped Event succeeded!",
        PrimaryButtonText = "OK",
        XamlRoot = this.XamlRoot
    };

    await dialog.ShowAsync();
}

private async void DoubleTapped_Event(object sender, Microsoft.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
{
    ContentDialog dialog = new ContentDialog
    {
        Title = "DoubleTapped Event",
        Content = "DoubleTapped Event succeeded!",
        PrimaryButtonText = "OK",
        XamlRoot = this.XamlRoot
    };

    await dialog.ShowAsync();
}

private async void PointerPressed_Event(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    ContentDialog dialog = new ContentDialog
    {
        Title = "PointerPressed Event",
        Content = "PointerPressed Event succeeded!",
        PrimaryButtonText = "OK",
        XamlRoot = this.XamlRoot
    };

    await dialog.ShowAsync();
}

Workaround

None

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

"Uno.Sdk": "5.4.10"

Affected platforms

Skia

IDE

Visual Studio 2022

IDE version

Version 17.11.4

agneszitte commented 1 month ago

(Possible similar related issue: https://github.com/unoplatform/uno/issues/14001)

fyi @dr1rrb, @ramezgerges