私はXamarin.FormsとC#を完全に新しくしているので、これがばかげた質問であれば私を許してください。 私はいくつかのエントリとピッカーでページを作成し、オブジェクトのカバーのプロパティを設定するために入力した値を使用する必要があります。ここ は私のカバーオブジェクトです:Xamarin.Formsオブジェクトのプロパティへのテキストのバインド
public class Cover
{
public enum Categories { Brasses, Percussions, Keyboards, Strings, Voices, Woodwinds, Other };
public User administrator { get; private set; }
public List<Track> tracks { get; private set; }
public String title { get; private set; }
public String author { get; private set; }
public String note { get; private set; }
public Boolean collaborative;
public Categories category;
public Cover(User administrator, String title, String author, String note, Categories category, Boolean collaborative, List<Track> tracks = null)
{
this.administrator = administrator;
this.tracks = tracks == null ? new List<Track>() : tracks;
this.title = title;
this.author=author;
this.category = category;
this.collaborative = collaborative;
}
public Cover() { }
そして、ここでは私のページです:
public createCover()
{
var userTest = new User("SmartPerson", "", null, null);
var entryTitle = new Entry
{
Placeholder = " ",
Keyboard = Keyboard.Text,
};
var entryAuthor = new Entry
{
Placeholder = " ",
Keyboard = Keyboard.Text,
};
var editorNote = new Editor
{
Text = "Ex: Metal Cover of the Super Mario main theme!",
FontSize = 10,
Keyboard = Keyboard.Text,
};
var pickerCategory = new Picker
{
Title = "Category",
VerticalOptions = LayoutOptions.Center
};
var categories = new List<string> { "Blues", "Country", "Dance", "Hip-Hop", "Jazz", "Metal", "Pop", "Rap", "Reggae", "Rock", "Classical", "Soundtracks", "Videogames", "Instrumental", "Anime", "Dubstep"};
foreach (string categoryName in categories)
{
pickerCategory.Items.Add(categoryName);
}
var collaborateSwitch = new Switch
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
var collaborate = new Label
{
Text = "Do you want other musicians to collaborate with you?",
FontSize = 15,
HorizontalOptions = LayoutOptions.Start,
};
var ok = new Button
{
Text = "Ok",
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)),
HorizontalOptions = LayoutOptions.Center,
};
ok.Clicked += OnOkClicked;
var stack = new StackLayout
{
Children =
{
entryTitle,
entryAuthor,
editorNote,
pickerCategory,
collaborate,
collaborateSwitch,
ok,
},
};
var scrollView = new ScrollView
{
VerticalOptions = LayoutOptions.FillAndExpand,
Content = stack
};
Content = scrollView;
this.Padding = new Thickness(20);
this.BindingContext = new Cover();
}
private void OnOkClicked(object sender, EventArgs e)
{
///???
}
}
}
私が欲しいもの、[OK]ボタンをクリックしたときに、オブジェクトのカバーをプロパティとしてこれらすべてのエントリ値を使用して作成されていることです(entryTitle.TextPropertyはcoverのTitleプロパティを埋めなければならないなど)しかし、私はそれを行う方法を見つけられません。 Ok氏がクリックしたときにのみ作成されるオブジェクトが必要です。 助けてくれてありがとう
問題を理解するために少し助けてもらえますか? 私はこれを克服するために勉強しなければならないことを知っていますが、これは大学のプロジェクトであり、私は道でそれをやる方法を学ぼうとしていますxD – SnowyNe