Объект типа "System.String" не может быть преобразован в тип "Xamarin.Forms.View"
У меня есть этот код, и он получает мне эту ошибку, как я могу это исправить?
Объект типа "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="Project1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Text"></Label>
Some text here
<Editor Text="I am an Editor" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Ответы
Ответ 1
Эта проблема решена, когда я удалил простой текст, который находится внутри 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>
Ответ 2
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>
Попробуйте сделать это сэр, таким образом измените текст для комментария
Привет