You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TapGestureRecognizer not working on a Frame in a grid on iOS or Mac #8330
Add the frame to a grid, run iOS or Mac and attempt to tap/click on it.
[EDIT], It might be more complex, it needs to be in a scrollview that spans all columns in the grid and in a custom layout control. Will put together an example when I get time.
[EDIT 2] Ok, nothing to do with my custom control. A grid, containing scrollview that spans columns, containing a frame that has a tap gesture recogniser added will show the problem.
This is using VSforMac, so the .net version is 6.0.301.
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
iOS 15
Did you find any workaround?
Nope
Relevant log output
No response
Reacted by Kalyxt, ShadowOfPhantom, Brandon Butler and David Ortinau
@rachelkang apologies for the delay, here you go. In the page constructor add the following code.
You will see that the tap gesture on the frames don't work at all.
But also, I found that setting the page content itself to a frame, the tap gesture doesn't work either. So it could be as simple as that to replicate:
Further info, swapping Frame for Border, the tap gestures work but you can't 'see' the border view.
[EDIT] Ok to see the background of the border view you must add a StrokeShape, which covers the shape of the border and has nothing to do with the background colour. You might want to take a look at that as well.
@PureWeen is this Frame not having gestures working when there is no child items a "feature" or "compatibility feature" of Frame? As far as I can tell, this is how Xamarin.Forms worked.
Adding a child or switching to Border makes it work again. How do we make a call on this issue?
@mattleibow, re your comment, "As far as I can tell, this is how Xamarin.Forms worked." We discovered this while migrating our code from Xamarin to MAUI. The Xamarin version of our app uses Frame in this way, and it does work on iOS as well as on Android.
Following up on your earlier comment, "Switching to a Border or a CollectionView seems to make it work again", I modified the test code from my original post to use CollectionView instead of ListView. When I ran it on an iPhone 7 with iOS 15.6.1 and an emulated iPhone 14 with iOS 16.0, the app crashed on startup. I then restored it to use ListView and the app ran as before -- i.e. the Frame ignores clicks, but the app didn't crash on startup. These tests were done using VS 17.4.2.
@mattleibow, I updated to VS 17.4.3 on my PC to see if that addressed the crash described in my previous post. That also forced me to update Xcode from 14.0.1 to 14.2 on our Mac.
The bad news is that our test app still crashes on iOS if the ListView is replaced with a CollectionView.
However, there is good news. Per your earlier suggestion, I changed the Frame to a Border, and now our custom button DOES respond to click events when the compound control is in a ListView.
Also, once I discovered that setting the Border control attribute StrokeShape="RoundRectangle 10" was equivalent to the Frame control's CornerRadius="10", the resulting control looks the same as it did on Xamarin using Frame. So, Border seems to be a viable workaround for Frame for the scenario described in my original post.
Activity
rachelkang commentedon Jun 27, 2022
Hi, @JohnHDev - thanks for opening this issue! Looking forward to investigating further once you share the example with us
JohnHDev commentedon Jul 1, 2022
@rachelkang apologies for the delay, here you go. In the page constructor add the following code.
You will see that the tap gesture on the frames don't work at all.
But also, I found that setting the page content itself to a frame, the tap gesture doesn't work either. So it could be as simple as that to replicate:
Let me know how you get on!
Thanks
John
JohnHDev commentedon Jul 1, 2022
Further info, swapping Frame for Border, the tap gestures work but you can't 'see' the border view.
[EDIT] Ok to see the background of the border view you must add a StrokeShape, which covers the shape of the border and has nothing to do with the background colour. You might want to take a look at that as well.
13 remaining items
mattleibow commentedon Dec 13, 2022
@PureWeen is this Frame not having gestures working when there is no child items a "feature" or "compatibility feature" of Frame? As far as I can tell, this is how Xamarin.Forms worked.
Adding a child or switching to Border makes it work again. How do we make a call on this issue?
awalker-dsg commentedon Dec 13, 2022
@mattleibow, re your comment, "As far as I can tell, this is how Xamarin.Forms worked." We discovered this while migrating our code from Xamarin to MAUI. The Xamarin version of our app uses Frame in this way, and it does work on iOS as well as on Android.
Following up on your earlier comment, "Switching to a Border or a CollectionView seems to make it work again", I modified the test code from my original post to use CollectionView instead of ListView. When I ran it on an iPhone 7 with iOS 15.6.1 and an emulated iPhone 14 with iOS 16.0, the app crashed on startup. I then restored it to use ListView and the app ran as before -- i.e. the Frame ignores clicks, but the app didn't crash on startup. These tests were done using VS 17.4.2.
mattleibow commentedon Dec 13, 2022
@awalker-dsg I was testing with the internal bits of 17.4.3 and maui 7.0.52. Both of these just shipped a few hours ago.
Maybe you have a more complex CollectionView so that may still have a crash. However, you can use a Border.
I will re-investigate this and see if I can try figure out why Xamarin.Forms worked and this does not as it is the same code...
mattleibow commentedon Dec 14, 2022
Just tested on iOS with Xamarin.Forms and indeed the touches work. Now the trick is to figure out why it is not working in MAUI...
awalker-dsg commentedon Dec 14, 2022
@mattleibow, I updated to VS 17.4.3 on my PC to see if that addressed the crash described in my previous post. That also forced me to update Xcode from 14.0.1 to 14.2 on our Mac.
The bad news is that our test app still crashes on iOS if the
ListViewis replaced with aCollectionView.However, there is good news. Per your earlier suggestion, I changed the
Frameto aBorder, and now our custom button DOES respond to click events when the compound control is in aListView.Also, once I discovered that setting the
Bordercontrol attributeStrokeShape="RoundRectangle 10"was equivalent to theFramecontrol'sCornerRadius="10", the resulting control looks the same as it did on Xamarin usingFrame. So,Borderseems to be a viable workaround forFramefor the scenario described in my original post.Many thanks for your help.