2017-03-07 62 views
3

当我尝试并创建XAML内容视图中Xamarin形式生成的代码隐藏抛出这个错误:生成的代码背后引发System.ArgumentNullException

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> 

回答

2

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

+0

甜蜜的答案兄弟! –