I'm trying to derive all may pages from a base class in my Visual Studio Xamarin Forms project, but it generates incorrect code that when compiled gives the follow error:
error CS0234: The type or namespace name 'local' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)
Its easily reproducible by the following steps:
- Create a Visual Studio project, 'Blank Xaml App', called AppTest.
- Add a new item (Forms Xaml Page) to the project, called BasePage.
Derive the existing MainPage.xaml from BasePage
<?xml version="1.0" encoding="utf-8" ?> <local.BasePage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:AppTest;assembly=Apptest" x:Class="local.MainPage"> <Label Text="Welcome to Xamarin Forms!" VerticalOptions="Center" HorizontalOptions="Center" /> </local.BasePage>
Derive the existing MainPage.xaml.cs from BasePage
public partial class MainPage : BasePage
Building the project generates the code:
public partial class MainPage : global::Xamarin.Forms.local.BasePage {
and gives the above CS0234 compile error.
Manually changing the generated code to:
public partial class MainPage : BasePage {
solved the issue, but isn't (for many reasons) a solution.
What am I doing wrong?
Doesn't anyone know how to make it generate the correct code?
Environment:
Visual Studio Pro 2015
Xamarin Forms 2.3.3.180
Microsoft.NETCore.UniversalWindowsPlatform 5.2.2
Any help is much appreciated.