private void OnRemove(IDataSourceViewModel viewModel)
        {
            int index = _observable.IndexOf(viewModel);

            if (index != -1)
            {
                _observable.RemoveAt(index);

                var merged = viewModel as MergedDataSourceViewModel;
                if (merged != null)
                {
                    IEnumerable <IDataSourceViewModel> items = merged.Observable;
                    foreach (IDataSourceViewModel item in items)
                    {
                        _observable.Insert(index++, item);
                        item.Parent = null;
                    }
                }
            }
            else if (viewModel.Parent != null)
            {
                ((MergedDataSourceViewModel)viewModel.Parent).RemoveChild(viewModel);
                _dataSources.Remove(viewModel.DataSource);
            }

            _allDataSourceViewModels.Remove(viewModel);
            _dataSources.Remove(viewModel.DataSource);
            UpdateRemoveCommands();
            _settings.SaveAsync();

            if (_selectedItem == null || _selectedItem == viewModel)
            {
                SelectedItem = _observable.FirstOrDefault();
            }
        }
        private void DissolveGroupIfNecessary(MergedDataSourceViewModel group)
        {
            if (group.ChildCount == 1)
            {
                int groupIndex = _observable.IndexOf(group);
                _observable.RemoveAt(groupIndex);
                _dataSources.Remove(group.DataSource);

                IDataSourceViewModel child = group.Observable.First();
                group.RemoveChild(child);
                _observable.Insert(groupIndex, child);
            }
        }