How can one create a base contentpage class to inherit from with xamarin forms?
I followed this forum for advice.
Everything is fine until I have to address the Xaml portion.
using System;
using Xamarin.Forms;
namespace MyProject
{
public class BaseContentPage : ContentPage
{
public BaseContentPage()
{
}
}
}
using System;
using Xamarin.Forms;
namespace MyProject
{
public partial class DashboardPage : BaseContentPage
{
public DashboardPage()
{
InitializeComponent();
}
void GoToJobDetailsPage(object sender, EventArgs args)
{
var masterPage = Application.Current.MainPage as MasterDetailPage;
masterPage.Detail = new H2HNavigationPage(new JobDetailPage());
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<d.BaseContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="clr-namespace:MyProject;assembly=MyProject"
x:Class="MyProject.DashboardPage"
ControlTemplate="{StaticResource Background}">
<ContentPage.Content>
</ContentPage.Content>
</d.BaseContentPage>
When I do this I get the compiler error
...DashboardPage.xaml.g.cs(64,64): Error CS0234: The type or namespace name 'd' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?) (CS0234)
Of course, I can figure that d alias is not in scope but what am I to do to create a custom base class content page?
in XAML, use ":" as the separator between the namespace and classname
<d:BaseContentPage>
...
</d:BaseContentPage>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With