ITGuru
ITGuru

Reputation: 117

Cant find page in Xamarin.forms

i have some trouble finding the page that i wanna navigate to in Xamarin.forms. I've been looking everywhere and it seems i'm the only one experiencing the issue.

I have these 3 files:

enter image description here

And yet i keep getting an error on the new HomePage (could not be found). The class is right there, it just cant find it..

public partial class MainPage : ContentPage
  {
    public MainPage()
    {
        InitializeComponent();
    }

    void LoginButton_Clicked(object sender, EventArgs e)
    {
       bool isIdEmpty = String.IsNullOrEmpty(idEntry.Text);
       bool isPasswordEmpty = String.IsNullOrEmpty(passwordEntry.Text);


        if(isIdEmpty || isPasswordEmpty)
        {

        } else
        {
            Navigation.PushAsync(new HomePage());
        }
    }
  }
}

Upvotes: 0

Views: 379

Answers (1)

Gerald Versluis
Gerald Versluis

Reputation: 33993

Check to see if both pages are in the same namespace. For instance, if MainPage is in the YourApp namespace:

namespace YourApp
{
    public class MainPage
    {
        // ... Your code
    }
}

and the HomePage is in the YourApp.Pages namespace, then you need to add a using statement to the top of your MainPage:

using YourApp.Pages;
// Probably other ones here

namespace YourApp
{
    public class MainPage
    {
        // ... Your code
    }
}

Or, you can specify the full namespace in your declaration: Navigation.PushAsync(new YourApp.Pages.HomePage());

Upvotes: 1

Related Questions