Xaml 类型为'的对象;System.String';无法转换为类型';Xamarin.Forms.View';
我有这个代码,它让我这个错误,我怎么能修复这个 “System.String”类型的对象无法转换为“Xamarin.Forms.View”类型Xaml 类型为'的对象;System.String';无法转换为类型';Xamarin.Forms.View';,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,我有这个代码,它让我这个错误,我怎么能修复这个 “System.String”类型的对象无法转换为“Xamarin.Forms.View”类型 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" x:Class=
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" x:Class="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
Some text here
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
<!--Some text here-->
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
这里有一些文字
当我删除StackLayout中的纯文本时,这个问题就解决了。因此,我将其更改为标签组件,并将纯文本放在text属性中
这是工作代码:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
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" x:Class="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
Some text here
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
<!--Some text here-->
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
试着这样做,先生,这样可以改变文本以供评论
问候请显示您的完整XAMLOkey已更新。您是否继承了页面上的ContentPage 1.xaml.cs?请阅读我的更新您应该:1)在上面的代码中包含有问题的注释,然后发布/接受解释如何删除注释并解决问题的答案;或2)删除问题。如前所述,没有人回答,这对任何人都没有帮助。啊。。。在两个小时试图找到解决方案后,我注意到由于
StackLayout
中的一个`字符,我收到了这个错误。。。非常感谢。