To be clear - it's not an "Collection ViewModel", it's an "CollectionView Model" :-)
 public void UpdateSelectedCollectionView(Action <CollectionViewModel> action)
 {
     if (this.SelectedCollectionViewModel == null)
     {
         this.SelectedCollectionViewModel = new CollectionViewModel();
     }
     action(this.SelectedCollectionViewModel);
     saveToFile();
 }
        public void AddCollectionView(string endpoint, string dbName, CollectionViewModel view)
        {
            var account = GetAccount(endpoint);

            if (account != null)
            {
                var coll = account.GetCollection(dbName, view.CollectionName);
                coll.Views.Add(view);
                saveToFile();
            }
        }
        public void RemoveCollectionView(string endpoint, string dbName, CollectionViewModel view)
        {
            var account = GetAccount(endpoint);

            if (account != null)
            {
                var coll         = account.GetCollection(dbName, view.CollectionName);
                var existingView = coll.Views.FirstOrDefault(v => v.ViewName == view.ViewName);
                if (existingView != null)
                {
                    coll.Views.Remove(existingView);
                    saveToFile();
                }
            }
        }
        public CollectionExpItemVM(DatabaseExpItemVM parentDatabaseExp, CollectionModel model, MainVM main, CollectionViewModel sourceView = null, CollectionExpItemVM viewSourceCollection = null) : base(main)
        {
            _parentDbExpItem = parentDatabaseExp;
            _model = model;
            if (sourceView != null)
            {
                this.View = sourceView;
                IsView = true;
                ViewSourceCollection = viewSourceCollection;
            }
            else
            {
                this.View = new CollectionViewModel();
                IsView = false;
            }
            this.ContextMenuItems.Add(new MenuItemVM()
            {
                Caption = "Refresh",
                Command = new LambdaCommand((o) => _wrkspc?.Refresh())
            });
           

            if (sourceView == null)
            {
                var savedCollection = Config.Instance.GetCollection(model.AccountEndpoint, model.DatabaseName, model.Name);
                if (savedCollection != null)
                {
                    this.IsExpanded = savedCollection.IsExpanded;
                    if (savedCollection.Views != null)
                    {
                        foreach (var view in savedCollection.Views)
                        {
                            this.Children.Add(new CollectionExpItemVM(parentDatabaseExp, model, main, view, this));
                        }
                    }
                }
                this.ContextMenuItems.Add(new MenuItemVM()
                {
                    Caption = "Delete collection",
                    Command = new LambdaCommand(async (o) =>
                    {
                        MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);
                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            await this._model.DeleteCollectionFromDatabase();
                            parentDatabaseExp.Children.Remove(this);
                        }
                    })
                });
            }
            else
            {
                this.ContextMenuItems.Add(new MenuItemVM()
                {
                    Caption = "Delete view",
                    Command = new LambdaCommand((o) =>
                    {
                        MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);
                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            this.ViewSourceCollection.Children.Remove(this);
                            this.ViewSourceCollection.IsSelected = true;
                            Config.Instance.RemoveCollectionView(_model.AccountEndpoint, _model.DatabaseName, this.View);
                        }
                    })
                });
            }
        }