public void AddRecentFile(string filename) { if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled") { return; } if (RecentDocuments.Contains(filename)) { RecentDocuments.Remove(filename); } RecentDocuments.Insert(0, filename); OnPropertyChanged(nameof(RecentDocuments)); if (RecentDocuments.Count > RecentDocumentsLength) { // the hard way to force collection to properly refresh so bindings work properly var recents = RecentDocuments.Take(RecentDocumentsLength); RecentDocuments.Clear(); foreach (var recent in recents) { RecentDocuments.Add(recent); } } }
public void AddRecentFile(string filename) { if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled") { return; } if (RecentDocuments.Contains(filename)) { RecentDocuments.Remove(filename); } RecentDocuments.Insert(0, filename); OnPropertyChanged(nameof(RecentDocuments)); if (RecentDocuments.Count > 12) { RecentDocuments = RecentDocuments.Take(12).ToList(); } }
public void AddRecentFile(string filename) { if (string.IsNullOrEmpty(filename) || filename.ToLower() == "untitled") { return; } if (RecentDocuments.Contains(filename)) { RecentDocuments.Remove(filename); } RecentDocuments.Insert(0, filename); OnPropertyChanged(nameof(RecentDocuments)); if (RecentDocuments.Count > RecentDocumentsLength) { RecentDocuments.Clear(); foreach (var recent in RecentDocuments.Take(RecentDocumentsLength)) { RecentDocuments.Add(recent); } } }