Example #1
0
        private async Task AddColumn()
        {
            var dialog = new NewColumnDialog();
            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                var columnName   = dialog.ColumnName;
                var maxTaskLimit = dialog.MaxTaskLimit;

                // Verify variable data is in correct format
                if (ViewModel.Columns.Any(x => x.ColumnName.Equals(columnName)))
                {
                    ViewModel.ShowInAppNotification("A column with that name already exists");
                    return;
                }
                else if (columnName == "" || maxTaskLimit < 0)
                {
                    ViewModel.ShowInAppNotification("Please fill out the required fields");
                    return;
                }

                // Continue with creating column
                var column = ViewModel.CreateColumn(columnName, maxTaskLimit);
                CustomKanbanColumn newColumn = new CustomKanbanColumn()
                {
                    Title      = column.ColumnName,
                    Categories = column.ColumnName,
                    CollapsedColumnTemplate = this.Resources["CollapsedColumnTemplate"] as ControlTemplate,
                    MaximumLimit            = column.MaxTaskLimit
                };

                var columnNameBinding = new Binding()
                {
                    Path   = new PropertyPath("ColumnName"),
                    Source = column,
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };

                var maxTaskLimitBinding = new Binding()
                {
                    Path   = new PropertyPath("MaxTaskLimit"),
                    Source = column,
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };

                // Set bindings
                newColumn.SetBinding(KanbanColumn.TitleProperty, columnNameBinding);
                newColumn.SetBinding(KanbanColumn.CategoriesProperty, columnNameBinding);
                newColumn.SetBinding(KanbanColumn.MaximumLimitProperty, maxTaskLimitBinding);

                // Add to kanban columns
                kanbanBoard.Columns.Add(newColumn);
            }
        }
Example #2
0
        private void ConfigureColumns()
        {
            ViewModel.ConfigureBoardColumns();
            var columns = ViewModel.Columns;

            // Set bindings and add columns to board
            foreach (var column in columns)
            {
                CustomKanbanColumn newColumn = new CustomKanbanColumn()
                {
                    Title      = column.ColumnName,
                    Categories = column.ColumnName,
                    CollapsedColumnTemplate = this.Resources["CollapsedColumnTemplate"] as ControlTemplate,
                    MaximumLimit            = column.MaxTaskLimit
                };

                var columnNameBinding = new Binding()
                {
                    Path   = new PropertyPath("ColumnName"),
                    Source = column,
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };

                var maxTaskLimitBinding = new Binding()
                {
                    Path   = new PropertyPath("MaxTaskLimit"),
                    Source = column,
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                };

                // Set bindings
                newColumn.SetBinding(KanbanColumn.TitleProperty, columnNameBinding);
                newColumn.SetBinding(KanbanColumn.CategoriesProperty, columnNameBinding);
                newColumn.SetBinding(KanbanColumn.MaximumLimitProperty, maxTaskLimitBinding);

                kanbanBoard.Columns.Add(newColumn);
            }
        }