0

How to open Menu Options in .NET MAUI on long press. Currently iPhone does this within photos like below video:

https://drive.google.com/file/d/1is7DjGFNWERy1xCx08j__kjc1ruQm1A-/view?usp=sharing

I want to implement this on Android and iOS devices. I am using CollectionView for rendering elements.

Is it possible in using .NET MAUI?

1 Answer 1

0

There is a proposal to include this in the MAUI Community Toolkit: [Proposal] TouchEffect.

And you requirement is implementing this on the Android and iOS. So you can try to use the platform code to do that:

For the android, you can use the ImageView's Long Click event to do that. Such as:

#if ANDROID (image.Handler.PlatformView as Android.Widget.ImageView).LongClick +=(s,e)=> { //do something } #end if 

And you can also declare a View.OnLongClickListener and then set the it for the image. Such as:

 public class MyListener : Java.Lang.Object, Android.Views.View.IOnLongClickListener { public bool OnLongClick(Android.Views.View? v) { //do what you want here } } ===== #if ANDROID (image.Handler.PlatformView as Android.Widget.ImageView).SetOnLongClickListener(new MyListener()); #end if 

And for the ios, you can use the UILongPressGestureRecognizer:

#if IOS (image.handler.PlatformView as UIKit.UIImageView).UserInteractionEnabled = true; (image.handler.PlatformView as UIKit.UIImageView).AddGestureRecognizer(new UILongPressGestureRecognizer(MethodName())); #endif 

And the effect after the long press, you can use the popup to do it.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. @Liyun Zhang - MSFT. I am still working on this. I'll update when I found one solution.
You are welcome. Looking forward to your feedback. @AjayKumar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.