private void InitializeBackgroundView(BackgroundViewModel background) { var view = background.CreateTileView(); background.Command = SelectBackgroundCommand; background.CommandParameter = background; BackgroundViews.Add(view); }
private void BackgroundsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (BackgroundViewModel background in e.NewItems) { var view = background.CreateTileView(); background.Command = SelectBackgroundCommand; background.CommandParameter = background; BackgroundViews.Add(view); } } else if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (BackgroundViewModel background in e.OldItems) { var view = BackgroundViews.First(v => v.DataContext == background); BackgroundViews.Remove(view); } } }