Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gestures still don't work on Label Spans #24432

Closed
CostasAthan opened this issue Aug 26, 2024 · 8 comments
Closed

Gestures still don't work on Label Spans #24432

CostasAthan opened this issue Aug 26, 2024 · 8 comments
Labels
area-controls-label Label, Span area-gestures Gesture types migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@CostasAthan
Copy link

CostasAthan commented Aug 26, 2024

Description

This is a problem supposedly solved and closed: #14410, but unfortunately in reality it still exists.

With .NET 8 and targeting Android 34 the gestures still don't work on Span tags of Labels.

I have provided a link to a repository that reproduces the bug.

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/CostasAthan/GesturesLabelSpansFailure

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 34

Did you find any workaround?

No.

Relevant log output

No response

@CostasAthan CostasAthan added the t/bug Something isn't working label Aug 26, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@dotnet dotnet deleted a comment Aug 26, 2024
@kevinxufei
Copy link

This issue has been verified using Visual Studio 17.12 Preview 1 (8.0.80 & 8.0.3). Can repro on android platform with sample project.

@kevinxufei kevinxufei added platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Aug 26, 2024
@samhouts samhouts added area-gestures Gesture types area-controls-label Label, Span labels Aug 27, 2024
@PureWeen PureWeen added this to the Backlog milestone Aug 29, 2024
@kubaflo
Copy link
Contributor

kubaflo commented Sep 1, 2024

I cannot reproduce it

Screen.Recording.2024-09-01.at.14.14.10.mov
public partial class MainPage : ContentPage
{
	public MainPage()
	{
		InitializeComponent();
		BindingContext = new MainPageViewModel();
	}
}

public class MainPageViewModel : INotifyPropertyChanged
{
	public MainPageViewModel()
	{
		OpenAlertCommand = new Command(()=>{
			Application.Current!.MainPage.DisplayAlert("sad","asd","sda");
		});
	}
	public Command OpenAlertCommand{get; set;}
	public event PropertyChangedEventHandler PropertyChanged;

	protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
        => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

@CostasAthan
Copy link
Author

@kubaflo

Is your version of code necessary? Shouldn't my version work too? It used to work with Xamarin.Forms.

@kubaflo
Copy link
Contributor

kubaflo commented Sep 1, 2024

@CostasAthan Yeah, you're incorrectly using Community Toolkit Rely Command: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/relaycommand

@karthikraja-arumugam
Copy link

@CostasAthan, the problem is with the relay command's name. When using the RelayCommand attribute, the command is generated by appending Command to the method name. So, in XAML, we need to use the method name with Command appended. If you update your relay command as shown below, it should work correctly.

[RelayCommand]
private async Task OpenWithRelay(string url)`
{
await Launcher.OpenAsync(url);
} 
<Span.GestureRecognizers>
    <TapGestureRecognizer Command="{Binding OpenWithRelayCommand}" CommandParameter="https://example.com/" />
</Span.GestureRecognizers>

@kubaflo
Copy link
Contributor

kubaflo commented Sep 4, 2024

@CostasAthan @karthikraja-arumugam is right! Let us know if it fixes your problem :)

@CostasAthan
Copy link
Author

CostasAthan commented Sep 4, 2024

@karthikraja-arumugam
It's not only the RelayCommand that does not work though. In my version of code neither ICommand nor Command work. ICommand definitely used to work in Xamarin.Forms implemented in the same way I have implemented it in the repository I have shared for this issue.

@kubaflo
Your ViewModel approach works fine. But the ICommand in Xamarin.Forms definitely used to work also in the way I have implemented my code. I don't know if that's a bug or if something has changed with MAUI.

@kubaflo kubaflo closed this as completed Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-label Label, Span area-gestures Gesture types migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants