public void ExecuteAddTemplateCommand()
        {
            try
            {
                var vm = TemplateDialogViewModel.CreateFrom(Kernel);
                vm.Add(_templatesSource.Select(t => t.Name));

                if (DialogService.ShowDialog(vm))
                {
                    _templatesSource.Add(vm);
                    Templates.MoveCurrentTo(vm);

                    _templateService.SaveTemplates(_localTemplateFolder, _templatesSource.Select(t => new Template(t)));
                    RefreshFrameworksFilter();
                }
            }
            catch
            {
                // ignored
            }
        }
        public void ExecuteEditTemplateCommand()
        {
            try
            {
                var vm = (TemplateDialogViewModel)Templates.CurrentItem;

                // Edit a copy so we don't have live updates in our list.
                var copyVm = TemplateDialogViewModel.CreateFrom(Kernel, vm);

                copyVm.Edit(_templatesSource.Select(t => t.Name));
                if (DialogService.ShowDialog(copyVm))
                {
                    // Success, copy fields back into our instance, save, and refresh frameworks (filter combobox).
                    vm.CopyFrom(copyVm);
                    _templateService.SaveTemplates(_localTemplateFolder, _templatesSource.Select(t => new Template(t)));
                    RefreshFrameworksFilter();
                }
            }
            catch
            {
                // ignored
            }
        }
        private void RefreshTemplates()
        {
            try
            {
                var templates = _templateService.LoadTemplates(_localTemplateFolder);

                bool restore  = Templates != null;
                int  savedPos = 0;
                if (restore)
                {
                    Templates.CurrentChanged -= TemplatesOnCurrentChanged;
                    Templates.Filter          = null;

                    // Save state of ListCollectionView to restore later.
                    savedPos = Templates.CurrentPosition;
                }

                _templatesSource = new ObservableCollection <TemplateDialogViewModel>(templates.Select(t => TemplateDialogViewModel.CreateFrom(Kernel, t)));
                Templates        = new ListCollectionView(_templatesSource)
                {
                    Filter = TemplateFilter
                };
                Templates.CurrentChanged += TemplatesOnCurrentChanged;

                if (restore)
                {
                    if (Templates.Count > savedPos)
                    {
                        Templates.MoveCurrentToPosition(savedPos);
                    }
                }
                else if (Templates.Count > 0)
                {
                    Templates.MoveCurrentToPosition(0);
                }

                RefreshFrameworksFilter();
            }
            catch (Exception)
            {
                throw;
            }
        }