Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object of type 'System.String' cannot be converted to type 'Xamarin.Forms.View'

I have this code and it gets me this error, how can I fix this ?

Object of type 'System.String' cannot be converted to type '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>
like image 228
tubefavorites.com Avatar asked Jun 29 '16 12:06

tubefavorites.com


2 Answers

This problem has solved when I removed the plain text that is inside the StackLayout. So I have changed it to a label component and have put the plain text in the text property.

This is the working code :

<?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>
like image 159
tubefavorites.com Avatar answered Sep 21 '22 07:09

tubefavorites.com


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>

Try to do this sir, this way change the text for comment

Regards

like image 35
Guilherme Marques Avatar answered Sep 22 '22 07:09

Guilherme Marques