2016-06-29 54 views
11

Ho questo codice e mi viene questo errore, come posso risolvere questo?L'oggetto di tipo 'System.String' non può essere convertito in tipo 'Xamarin.Forms.View'

L'oggetto di tipo "System.String" non può essere convertito in tipo "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

prega mostra il tuo XAML –

+0

Okey aggiornato d. –

+0

Stai ereditando da ContentPage sul tuo Page1.xaml.cs? –

risposta

18

Questo problema è risolto quando ho rimosso il testo che è all'interno del stackLayout. Quindi l'ho modificato in un componente di etichetta e ho inserito il testo normale nella proprietà text.

Questo è il codice di lavoro:

<?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

Ah ... dopo 2 ore cercando di trovare una soluzione, ho notato che a causa di un 'carattere all'interno di' StackLayout' stavo ricevendo questo errore ... Grazie! –

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> 

Provate a fare questo signore, in questo modo modificare il testo per il commento

saluti