C# XamlParseException:无法分配属性";“内容”:“之间的类型不匹配”;System.String“;及;“Xamarin.Forms.View”;
我目前正在学习有关Xamarin的模块,并尝试一些示例代码: MainPage.xamlC# XamlParseException:无法分配属性";“内容”:“之间的类型不匹配”;System.String“;及;“Xamarin.Forms.View”;,c#,xamarin.android,xamarin.forms,C#,Xamarin.android,Xamarin.forms,我目前正在学习有关Xamarin的模块,并尝试一些示例代码: 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="
<?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:Modul2"
x:Class="Modul2.MainPage">
<ScrollView VerticalOptions="FillAndExpand">
<StackLayout HeightRequest="1000">
<Label Text="Practice 2.1" FontSize="40" HorizontalOptions="Center"/>
<Label x:Name="lblDetail" Text="This Label is use to show the details"
FontSize="20" HorizontalOptions="CenterAndExpand"/>
<Button x:Name="btnHello" Text="Hello Button" HorizontalOptions="Center"
VerticalOptions="Fill" />
<Entry x:Name="entryHello" Placeholder="Username" VerticalOptions="Center"
Keyboard="Text"/>
<Image x:Name="helloImg" Source="icon.png" Aspect="AspectFit"
HorizontalOptions="Center" VerticalOptions="Fill"/>
</StackLayout>
</ScrollView>
</ContentPage>
但是,当我使用android emulator运行代码时,它会显示一个错误,即:
未处理的异常:
Xamarin.Forms.Xaml.XamlParseException:无法分配属性“Content”:在“System.String”和“Xamarin.Forms.View”之间类型不匹配“
有人能帮忙吗?它在哪一行抛出该异常?
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
btnHello.Clicked += BtnHello_Clicked;
}
private void BtnHello_Clicked(object sender, EventArgs e)
{
lblDetail.Text = entryHello.Text;
}
}