void HandleColumnsOrItemsSourceChanged() { if (Columns != null) { //todo: make a different one for when we activate the smooth mode. List <KanBanColumn> columns = (List <KanBanColumn>)(IEnumerable <KanBanColumn>) Columns.ToList(); //calling ToList so we do not modify the original list. // Add the "Unclassified" Column: KanBanColumn unclassifiedColumn = new KanBanColumn() { Header = "Unclassified", HeaderTemplate = ColumnHeaderTemplate }; columns.Add(unclassifiedColumn); // Create a ViewModel for each Column: ObservableCollection <ColumnViewModel> columnViewModels = new ObservableCollection <ColumnViewModel>(); foreach (KanBanColumn column in columns) { column._kanBanControl = this; columnViewModels.Add(new ColumnViewModel(column, ItemTemplate)); } _kanBanViewModel.Columns = null; _kanBanViewModel.Columns = columnViewModels; SetItemsInViewModelColumns(columnViewModels); } //todo: else put everything in an "UNCLASSIFIED" column }
public ColumnViewModel(KanBanColumn column, DataTemplate itemTemplate) { ColumnDefinition = column; ItemTemplate = itemTemplate; OpenContextMenuColumnModification_Command = new OpenContextMenuColumnModificationCommand(this); ItemDrop_Command = new ItemDropCommand(this); ShowMore_Command = new ShowMoreCommand(this); }
public void Execute(object parameter) { var childWindow = new EditKanBanColumnChildWindow(); KanBanColumn newColumn = new KanBanColumn() { Header = "", Id = "" }; childWindow.DataContext = newColumn; childWindow.Closed += EditKanBanColumnChildWindow_Closed; childWindow.Show(); }
internal void MenuItemEditColumn_Click(object sender, RoutedEventArgs e) { var childWindow = new EditKanBanColumnChildWindow(); KanBanColumn dummyColumn = new KanBanColumn() { Header = ColumnDefinition.Header, Id = ColumnDefinition.Id }; childWindow.DataContext = dummyColumn; childWindow.Closed += EditKanBanColumnChildWindow_Closed; childWindow.Show(); ((ContextMenu)((MenuItem)sender).Tag).IsOpen = false; }
private void EditKanBanColumnChildWindow_Closed(object sender, EventArgs e) { EditKanBanColumnChildWindow cw = (EditKanBanColumnChildWindow)sender; if (cw.DialogResult == true) { KanBanColumn dummyColumn = (KanBanColumn)cw.DataContext; ColumnDefinition.Header = dummyColumn.Header; if (ColumnDefinition.Id != dummyColumn.Id) { ColumnDefinition.Id = dummyColumn.Id; //force a refresh of the KanBanControl: var columns = ColumnDefinition._kanBanControl.Columns; ColumnDefinition._kanBanControl.Columns = null; ColumnDefinition._kanBanControl.Columns = columns; } } }
private void EditKanBanColumnChildWindow_Closed(object sender, EventArgs e) { EditKanBanColumnChildWindow cw = (EditKanBanColumnChildWindow)sender; if (cw.DialogResult == true) { //Get the newly created Column's informations: KanBanColumn newColumn = (KanBanColumn)cw.DataContext; if (_kanBanControl.ColumnHeaderTemplate != null) { newColumn.HeaderTemplate = _kanBanControl.ColumnHeaderTemplate; } //Add the newly created Column to the columns of the KanBanControl and force a refresh var columns = _kanBanControl.Columns; _kanBanControl.Columns = null; columns.Add(newColumn); _kanBanControl.Columns = columns; } }