Flyout menu is not visible in pages in xamarin forms

543 views Asked by At

I created a new project with default template containing already a login button, logout button etc. I followed a tutorial step-by-step which creates login and register. After logging in, you are redirected to HomePage. In my home page the flyout menu is not visible.

here is the code from my LoginPage.xaml.cs

namespace final1scratch.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class LoginPage : ContentPage
    {
        public LoginPage()
        {
            InitializeComponent();
            this.BindingContext = new LoginViewModel();
        }

   async void Handle_Clicked(object sender, System.EventArgs e)
    {
        await Navigation.PushAsync(new RegistrationPage());
    }

    async void Handle_Clicked_1(object sender, System.EventArgs e)
    {
        var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabse.db");
        var db = new SQLiteConnection(dbpath);
        var myquery = db.Table<RegUserTable>().Where(u => u.UserName.Equals(EntryUser.Text) && u.Password.Equals(EntryPassword.Text)).FirstOrDefault();
        if (myquery != null)
        {
            App.Current.MainPage = new NavigationPage(new HomePage());
        }

        else
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                var result = await this.DisplayAlert("Error", "Failed User Name and Password", "Yes", "Cancel");

                if (result)
                    await Navigation.PushAsync(new LoginPage());
                else
                {
                    await Navigation.PushAsync(new LoginPage());
                }

            });
        }
    }
}

And here is my HomePage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="final1scratch.Views.HomePage">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
            
            <Button Text="Logout" Clicked="Handle_Clicked" TextColor="Black"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Here is a screenshot after the user has logged in

click to see image

0

There are 0 answers