2017-12-30 4 views
2

スタックレイアウトのChildren.Add()関数に問題があります。 「SettersExtentions.Add(IList、Bindable Property、object)」の必須の仮パラメータ 'value'に対応する引数がありません。エラーは、すべての.Add単語の下に波の赤い下線です。XamarinフォームでChildren.Addを使用するとエラーが発生する

public class LoginPage : ContentPage 
{ 
    public string email { get; set; } 
    public string password { get; set; } 
    Entry emailBox = new Entry(); 
    Entry passwordBox = new Entry(); 
    Button createAccount = new Button(); 
    Button forgotPassword = new Button(); 
    Layout layout = new StackLayout(); 


    public LoginPage() 
    { 
     Title = "Login"; 
     emailBox.Placeholder = "email"; 
     passwordBox.Placeholder = "password"; 
     passwordBox.IsPassword = true; 

     createAccount.Text = "Create Account"; 
     createAccount.Font = Font.SystemFontOfSize(NamedSize.Large); 
     createAccount.BorderWidth = 1; 
     createAccount.HorizontalOptions = LayoutOptions.Center; 
     createAccount.VerticalOptions = LayoutOptions.CenterAndExpand; 

     forgotPassword.Text = "Forgot Password"; 
     forgotPassword.Font = Font.SystemFontOfSize(NamedSize.Large); 
     forgotPassword.BorderWidth = 1; 
     forgotPassword.HorizontalOptions = LayoutOptions.Center; 
     forgotPassword.VerticalOptions = LayoutOptions.CenterAndExpand; 

     layout.VerticalOptions = LayoutOptions.CenterAndExpand; 

     layout.Children.Add(emailBox); 
     layout.Children.Add(passwordBox); 
     layout.Children.Add(createAccount); 
     layout.Children.Add(forgotPassword); 

     Content = layout; 

    } 

    public void Check(string email, string password, string cpassword) 
    { 

    } 
} 
+0

変更 'Layout Layout = new StackLayout();'を 'StackLayout layout = new StackLayout();'に変更します。 – Nkosi

答えて

3

Layout.Childrenはそうあなたが文句を言わない、それに追加できるように読み取り専用IReadOnlyList<Element>です。

しかしStackLayout.Childrenあなたが子供

これは、あなたがレイアウトに子要素を追加することができるようになります

Layout layout = new StackLayout(); 

StackLayout layout = new StackLayout(); 

に変更を加えることができます IList<T>です。

関連する問題