I have a master detail page operating on my app. The standard method for opening the master page is to either select the burger menu icon or slide from the left. One of my detail pages happens to use a carousel page. The swiping from the left can therefore either open the master page or slide the carousel to the left (rather irritating if the wrong event occurs).
In order to stop the Master page appearing when sliding from the left, I've set IsGestureEnabled to false. However this stops the Master Page from appearing at all. Despite their being haptic feedback when pressing the burger menu icon, it does nothing.
Is there a way to force the slide gesture to be ignored on a MasterDetailPage and not the tap gesture on the icon?
Here's a very simple app that has a MasterDetailPage and IsGestureEnabled set to false. The Master page will not open. https://www.dropbox.com/s/rkm5eph3vr38avm/MasterDetailPageTest.zip?dl=0
I've come up with a bit of a workaround by creating a custom renderer for MasterDetailPage. It should suit my needs for now.
public class MyMasterDetailPageRenderer : Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer
{
public override bool OnTouchEvent(MotionEvent e)
{
if (IsDrawerOpen(Android.Support.V4.View.GravityCompat.Start))
return base.OnTouchEvent(e);
else
{
if (e.Action == MotionEventActions.Up || e.Action == MotionEventActions.Down)
return base.OnTouchEvent(e);
else
{
CloseDrawers();
return true;
}
}
}
}
The assembly line needs to be added outside of the namespace:
[assembly: ExportRenderer(typeof(MyMasterDetailPage), typeof(MyMasterDetailPageRenderer))]
This doesn't completely solve the issue, but the master page does not open when swiping anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With