private void RefreshAvailableDecks() { if (AvailableDecks.Count == 0) { for (var i = 1; i <= 9; i++) { var key = i.ToString(CultureInfo.InvariantCulture); var model = new AvailableDecksModel { Slot = key, AvailableDecks = new BindableCollection <DeckModel>(Decks.Where(x => x.Key == key || String.IsNullOrEmpty(x.Key))), SelectedDeck = Decks.FirstOrDefault(x => x.Key == key) }; model.PropertyChanged += AvailableDecksModel_OnPropertyChanged; AvailableDecks.Add(model); } NotifyOfPropertyChange(() => AvailableDecks); } else { for (var i = 1; i <= 9; i++) { var key = i.ToString(CultureInfo.InvariantCulture); AvailableDecks[i - 1].AvailableDecks = new BindableCollection <DeckModel>(Decks.Where(x => x.Key == key || String.IsNullOrEmpty(x.Key))); AvailableDecks[i - 1].PropertyChanged -= AvailableDecksModel_OnPropertyChanged; AvailableDecks[i - 1].SelectedDeck = Decks.FirstOrDefault(x => x.Key == key); AvailableDecks[i - 1].PropertyChanged += AvailableDecksModel_OnPropertyChanged; } NotifyOfPropertyChange(() => AvailableDecks); } }
protected void RemoveFromSlot(AvailableDecksModel model) { RemoveFromSlot(model.Slot); }