小编jas*_*key的帖子

自动生成的XAML.g.cs文件在Xamarin Forms PCL项目中不可编译

我有一个Xamarin表单(我正在使用Xamarin Studio 5.7)项目,其中包含一个包含UI组件的常见PCL.我只是使用Classes(没有XAML设计师)来启动我的项目,它运行良好,编译,并有一个带有几个子页面的ContentPage.我决定添加一个新的AboutPage.xaml和AboutPage.cs文件,然后使用UI编辑我的表单.所以,我通过新文件创建了我的新页面... Forms ContentPage XAML .....正如我上面提到的,它创建了我的两个文件.

AboutPage.cs AboutPage.xaml

生成的文件看起来像这样......

AboutPage.cs

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace IPSND.Xamarin
{
    public partial class AboutPage : ContentPage
    {
        public AboutPage ()
        {
            InitializeComponent ();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

AboutPage.xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="IPSND.Xamarin.AboutPage">
    <ContentPage.Content>
        <StackLayout>
            <Image Id="ImageLogo" Aspect = "AspectFit"></Image>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

现在,这看起来很好,我确保我的类声明包含命名空间.但是,当我编译时,生成的AboutPage.xaml.g.cs文件如下所示...请注意using语句如何包含在命名空间内而不是文件的顶部.不幸的是,这是不可编译的.

我在这做错了什么?

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.18408
//
//     Changes to this file may cause incorrect behavior …
Run Code Online (Sandbox Code Playgroud)

c# android portable-class-library xamarin xamarin.forms

9
推荐指数
1
解决办法
3620
查看次数