I am trying to make a Navigation bar in Xamarin. I created a Context view with an x:name of Placeholder in my MainPage.xaml and when I go to call it in the xaml.cs page it says
Your Page
class is simply missing the call to InitializeComponent
. That is a method call to the partial class of the page which will internally do some processing for the XAML file (more information can be found here).
public partial class HomePage : ContentPage
{
public HomePage()
{
InitializeComponent();
}
void Icon1_Tapped (object sender, System.EventArgs e)
{
var page = new HomePage();
PlaceHolder.ContentView = page.Content;
}
}
Also please make sure the xaml file has the class type correctly set. In case you are using a ContentPage
, you should have something like this: