【发布时间】:2019-01-30 15:54:08
【问题描述】:
我对 Xamarin 形式完全陌生。我想我要问的问题不会太好,但是我遇到的问题很奇怪,我不知道如何解决。
问题: 我在 Visual Studio 2017 中创建了一个全新的跨平台项目。 并且写了一些代码,当我运行我的应用程序时,构建解决方案失败了。
MainPage.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"
xmlns:local="clr-namespace:HelloWorld"
x:Class="HelloWorld.MainPage">
<StackLayout>
<!-- Place new controls here -->
<Label x:Name="_label" Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
<Entry x:Name="EnterYourName" Placeholder="Write your name"/>
<Button Text="Say Hello !" Clicked="Button_Clicked" />
</StackLayout>
</ContentPage>
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Form;
namespace HelloWorld
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
void Button_Clicked(object sender, EventArgs e)
{
_label.Text = "Welcome" + " " + EnterYourName.Text;
}
}
}
错误:
所有必要的 using 语句都包括在内,当我点击 在构建解决方案时它给了我这个错误......
- 找不到类型或命名空间名称“系统”(您是否缺少 using 指令或程序集引用。)
- 找不到类型或命名空间名称“Xamarin”(您是否缺少 using 指令或程序集引用。)
- 未定义或导入预定义类型“System.Void”。等等。
如何解决这个问题?我将非常感谢。
谢谢。
【问题讨论】:
-
错误信息是什么?
-
如果您的构建失败,应该有一些解释性错误消息告诉您原因。还有
Text:"Say Hello !"是无效的,你的意思是Text="Say Hello !" -
命名空间'System'的类型没有被引用等等......@Joe Seweli
-
Cicked="Button_Clicked",除了Clicked属性拼写错误,其余代码看起来正常。
标签: c# xamarin.forms