Пример #1
0
        public BacklogUserControl()
        {
            TasksSourceChanged += (sender, args) =>
            {
                ListBacklogTasks.ItemsSource = this.TasksSource;
                ICollectionView backlogTasksView = CollectionViewSource.GetDefaultView(ListBacklogTasks.ItemsSource);
                backlogTasksView.SortDescriptions.Add(new SortDescription(nameof(Task.Priority), ListSortDirection.Ascending));
            };

            IsInEditModeChanged += async(sender, args) =>
            {
                if (IsInEditMode)
                {
                    return;
                }

                try
                {
                    if (ListBacklogTasks.SelectedItem is TaskViewModel task)
                    {
                        await ViewModelMapper.SaveTaskNameAsync(task);
                    }
                    else if (ListBacklogTasks.SelectedItem is StepViewModel step)
                    {
                        await ViewModelMapper.SaveStepDescriptionAsync(step);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            };

            InitializeComponent();
        }