生成的代码背后抛出System.ArgumentNullException

时间:2017-03-07 00:40:46

标签: c# xaml xamarin.forms

当我尝试在Xamarin Forms中使用XAML创建内容视图时,生成的代码隐藏会抛出此错误:

System.ArgumentNullException: Value cannot be null. Parameter name: clrNamespace
at this.LoadFromXaml(typeof(MyXamlPage));
at InitializeComponent()

XAML:

<ContentPage
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Adapt.Presentation.XamarinForms.MyXamlPage"
         Title="My Xaml Page">
    <ContentPage.Content>
        <Grid>
        </Grid>
    </ContentPage.Content>
</ContentPage>

1 个答案:

答案 0 :(得分:2)

您只需要将xmlns="http://xamarin.com/schemas/2014/forms"添加到根元素即可。抛出此错误是因为没有为根元素定义名称空间,因此解析器无法确定要解析的XML类型。