XamlParseException:无法分配属性"内容":类型不匹配" System.String"和" Xamarin.Forms.View"

时间:2017-05-23 10:28:43

标签: c# xamarin.android xamarin.forms

我目前正在学习有关Xamarin的模块,并尝试了一些示例代码:

MainPage.xaml中

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
    client.close();            
}
else
{
    client.release();
}

MainPage.xaml.cs中

<?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模拟器运行代码时,它会显示一个错误:

未处理的例外情况: Xamarin.Forms.Xaml.XamlParseException:无法分配属性&#34;内容&#34;:类型不匹配&#34; System.String&#34;和&#34; Xamarin.Forms.View&#34;

任何人都可以帮忙???

0 个答案:

没有答案