public void JobFilterChanged() { // Determine whether the button should be active ClearJobFilter.RaiseCanExecuteChanged(); // Clear the collection FilteredJobs.Clear(); // Add all jobs that match the filter if (SelectedCraft != null) { if (SelectedCraft.Jobs.Any()) { foreach (Job j in SelectedCraft.Jobs) { if (j.Name.ToLower().Contains(JobFilterText.ToLower())) { FilteredJobs.Add(j); } } } } // If a "Custom" entry exists, put it first if (FilteredJobs.Any(x => x.Name == "Custom")) { int index = FilteredJobs.IndexOf(FilteredJobs.First(x => x.Name == "Custom")); if (index != 0) { FilteredJobs.Move(index, 0); } } }
public void LoadJobs() { Jobs.Clear(); FilteredJobs.Clear(); // Pull the Job list from each Craft into Jobs list foreach (Craft c in Crafts) { // Alphabetize c.Jobs.Sort((x, y) => String.Compare(x.Name, y.Name)); //Add to Jobs foreach (Job j in c.Jobs) { Jobs.Add(j); } } }