我正在处理HighScore
页面并需要保存HighScores
列表。
不幸的是,我无法找到有关保存列表集合的任何信息。
我的基础代码如下:
public ObservableCollection<User> HighScores { get; set; }
DateTime Datum = DateTime.Now;
this.HighScores = new ObservableCollection<User>();
this.HighScores.Add(new User() { Name = "Michel Platini", HighScore = 10, Datum = "01/05/1990" });
this.HighScores.Add(new User() { Name = "Pele", HighScore = 12, Datum = "09/12/2004" });
this.HighScores.Add(new User() { Name = "Ronaldo", HighScore = 14, Datum = "05/05/1977" });
this.HighScores.Add(new User() { Name = "Cacau", HighScore = 15, Datum = "17/04/1989" });
this.HighScores = new ObservableCollection<User>(this.HighScores.OrderByDescending(x => x.HighScore));
this.DataContext = this;
this.InitializeComponent();
this.DataContext = this;
private void SaveScore_Click(object sender, RoutedEventArgs e)
{
m = string.Format("{0:dd/MM/yyyy}", Datum);
i = tbName.Text;
HighScores.Add(new User() { Name = i, HighScore = z, Datum = m });
this.HighScores = new ObservableCollection<User>(this.HighScores.OrderByDescending(x => x.HighScore));
我希望有人想帮助我,因为我拼命寻找好几天(没有任何进展),