示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        public MainViewModel()
        {
            ApplicationName = "OPEN TODO";
            Filters         = new ObservableCollection <FiltersViewModel>();

            EditTaskCommand = new DelegateCommand <Task>(OnEditCommandExecuted);
            AddCommand      = new DelegateCommand(OnAddCommandExecuted);

            _persistenceService = new XmlPersistenceService();
            _taskLists          = _persistenceService.GetTaskLists();
            _tasks = _persistenceService.GetTasks();

            // refresh the list of filters. i.e. fixed labels + taskLists
            _taskLists.CollectionChanged += (o, e) => InitFilters(_tasks);

            ViewModelLocatorService.SetViewModel(typeof(EditListsView), new EditListsViewModel(_taskLists));
            ViewModelLocatorService.SetViewModel(typeof(AddTaskView), new AddTaskViewModel(_tasks, _taskLists));
            ViewModelLocatorService.SetViewModel(typeof(EditTaskView), new EditTaskViewModel(_tasks, _taskLists));
            ViewModelLocatorService.SetViewModel(typeof(About), new AboutViewModel());

            ShowAboutCommand    = new DelegateCommand(OnShowAboutCommand);
            ShowSettingsCommand = new DelegateCommand(OnShowSettings);
        }