OnOptionsItemSelected Never Called when use MasterDetailPage's Detail as NavigationPage, and I can't intercept the software back button in the navigation bar.
It's very important to my team to do navigation through WebView and local Pages...
I want to intercept the software back button event when use MasterDetailPage.
The OnOptionsItemSelected method do triggered when the mainpage is a NavigationPage, but when use MasterDetailPage, it's never called.
None
I wrote a demo here
I think this is not a bug, you will need a CustomRenderer or something similar for a navigation update.
We could make this easy so marking as a enhancement
Yes, I finally did this through a custom renderer, but I think it’s too complex to implement this
@yanshouwang can you share your implementation so we can try to make it easier ?
@rmarinho ok, I'll try to write a sample tomorrow~
@rmarinho Hi, I wrote a sample just now, and I only did this on iOS and Android,
the sample is here
@rmarinho the issue with XF is that it blocks developers from intercepting the back button behaviour (main reason for overriding OnOptionsItemSelected), without giving developers a mechanism to detect and potentially cancel the back operation.
@yanshouwang I took a look at your implementation and it looks good. Although on Android you can implement the IOnClickListener interface (see https://github.com/MvvmCross/MvvmCross/issues/3124#issuecomment-425762792) which might be simpler.
cc @davidortinau
Please try and solve this issue, I've just spent too much time trying to add this seminally simple ability to my app.
I am not entirely sure this is only related to the MasterDetailPage, I get the same behaviour when using standard navigation pages.
All was working fine when my MainActivity inherited from FormsApplicationActivity however I am having issues when my MainAcitivity inherits from FormsAppCompatActivity.
Just adding a +1 of frustration here too. Chasing round from Udara Alwis' blog post (which I couldn't get to work here) and ultimately realising that there really is no clean/straightforward way of hooking into that back button on the Android Toolbar.
And if not a clean event we can hook, then at least a canonical official Xamarin 'how to do this' blog post would be really welcome.
Still no solution? +1 frustration
Most helpful comment
@rmarinho the issue with XF is that it blocks developers from intercepting the back button behaviour (main reason for overriding OnOptionsItemSelected), without giving developers a mechanism to detect and potentially cancel the back operation.
@yanshouwang I took a look at your implementation and it looks good. Although on Android you can implement the IOnClickListener interface (see https://github.com/MvvmCross/MvvmCross/issues/3124#issuecomment-425762792) which might be simpler.
cc @davidortinau