I am working on xamarin forms. I am using Master detail page to open left menu. And its working fine. Right now menu hide only when user click on menu icon on top. But I want if menu is open, then if user click anywhere on screen, menu should hide.
How I can do this?
I've managed to do it using a custom renderer.
[assembly: ExportRenderer(typeof(BaseMasterDetailPage), typeof(MyMasterDetailPageRenderer))]
namespace Driver.Droid.Renderers
{
public class MyMasterDetailPageRenderer : MasterDetailPageRenderer
{
public override bool OnTouchEvent(Android.Views.MotionEvent e)
{
if (e.Action == Android.Views.MotionEventActions.Up)
new Task(CloseDrawers).Start(TaskScheduler.FromCurrentSynchronizationContext());
return base.OnTouchEvent(e);
}
}
}
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