2016-06-29 22 views
11

私はこのコードを持っており、このエラーが表示されます。タイプ 'System.String'のオブジェクトをタイプ 'Xamarin.Forms.View'に変換できません

'System.String'タイプのオブジェクトは 'Xamarin.Forms.View'タイプに変換できません。

XAML:私はStackLayout内にあるプレーンテキストを削除する場合

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

をテキストを変更してください。完全なXAMLを表示する –

+0

Okeyが更新されましたd。 –

+0

Page1.xaml.csのContentPageを継承していますか? –

答えて

18

この問題は解決しました。だから私はそれをラベルコンポーネントに変更し、プレーンテキストを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

ああ... 2時間後に解決策を見つけようとしたとき、私はこのエラーを受け取っていた 'StackLayout'の中の1文字のため気づきました...ありがとう! –

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> 

この先生をしようと、このようにコメント

よろしく

関連する問題