Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Derived Pages generate incorrect code.

$
0
0

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:

  1. Create a Visual Studio project, 'Blank Xaml App', called AppTest.
  2. Add a new item (Forms Xaml Page) to the project, called BasePage.
  3. 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>
  4. 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. :)


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>