我在Stack Layout的Children.Add()函数中遇到了一些问题。下面的代码中有一个错误,上面写着“没有与'SettersExtentions.Add(IList,Bindable Property,object)'”所需的形式参数'value'相对应的参数。所有.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)
{
}
}
qazxsw poi是一个只读qazxsw poi所以你将无法添加它。
然而Layout.Children
是IReadOnlyList<Element>
,它允许你添加孩子
更改
StackLayout.Children
至
IList<T>
这将允许您能够将子元素添加到布局中。