I have five pages in my application and if App.quizRunning == true and the current page is Japanese.PhrasesFrame I need to be able to stop the action of tapping on any of the tabs from doing anything:
namespace Japanese {
public partial class MainPage : TabbedPage {
public MainPage() {
InitializeComponent();
App.cardsPage = new Cards();
App.homePage = new HomePage();
App.helpPage = new HelpPage();
App.settingsPage = new SettingsPage();
App.phrasesPage = new PhrasesFrame(this);
Children.Add(App.navHomePage);
Children.Add(App.navHelpPage);
Children.Add(App.navSettingsPage);
Children.Add(App.navCardsPage);
Children.Add(App.navPhrasesFrame);
}
}
}
So far I have an iOS Solution that I came up with. If anyone sees anything wrong with this I would appreciate there advice:
using System;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using System.Diagnostics;
using Japanese.Enums;
[assembly: ExportRenderer(typeof(TabbedPage), typeof(Japanese.iOS.TabbedPageRenderer))]
namespace Japanese.iOS {
public class TabbedPageRenderer : TabbedRenderer {
private MainPage _page;
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement != null) { _page = (MainPage)e.NewElement; }
else { _page = (MainPage)e.OldElement; }
try {
var tabbarController = (UITabBarController)this.ViewController;
if (null != tabbarController)
tabbarController.ViewControllerSelected += OnTabbarControllerItemSelected;
}
catch (Exception exception) { Console.WriteLine(exception); }
}
private void OnTabbarControllerItemSelected(object sender, UITabBarSelectionEventArgs eventArgs)
{
if (!(_page.CurrentPage is Japanese.PhrasesFrame) && App.quizRunning == true) {
_page.CurrentPage = App.navPhrasesFrame;
}
}
}
}
Now I am looking for an Android solution but have been unable to find anything at all.
Does anyone have any ideas how I can do this with an Android renderer?