private void ApplyGridSettings() { if (ColumnSettings == null) { return; } RequiredColumnId = GetColumnId(DataGrid.Columns[0]); foreach (var col in DataGrid.Columns) { var columnId = GetColumnId(col); if (columnId == null) { continue; } var cd = ColumnSettings.FirstOrDefault(x => x.Id == columnId); if (cd == null) { cd = new ColumnSettingsViewModel(CreateColumnSettings(col)); ColumnSettings.Add(cd); } cd.ApplyColumnSettings(col); cd.ApplyColumnOrdering(DataGrid.Columns.Count, col); cd.Required = RequiredColumnId == columnId; } if (ColumnSort != null) { DataGrid.Columns[ColumnSort.Index].SortDirection = ColumnSort.Direction; } DataGrid.ContextMenu = CreateContextMenu(); }
private void SwapColumnOrders(ColumnSettingsViewModel vm, int targetOrder) { // Get the column with targetOrder var col = Settings.FirstOrDefault(x => x.Order == targetOrder); if (col == null) { return; } var tmp = col.Order; col.Order = vm.Order; vm.Order = tmp; SettingsView.Refresh(); }
private void ApplyGridSettings() { if (ColumnSettings == null) return; RequiredColumnId = GetColumnId(DataGrid.Columns[0]); foreach (var col in DataGrid.Columns) { var columnId = GetColumnId(col); if (columnId == null) continue; var cd = ColumnSettings.FirstOrDefault(x => x.Id == columnId); if (cd == null) { cd = new ColumnSettingsViewModel(CreateColumnSettings(col)); ColumnSettings.Add(cd); } cd.ApplyColumnSettings(col); cd.ApplyColumnOrdering(DataGrid.Columns.Count, col); cd.Required = RequiredColumnId == columnId; } if (ColumnSort != null) { DataGrid.Columns[ColumnSort.Index].SortDirection = ColumnSort.Direction; } DataGrid.ContextMenu = CreateContextMenu(); }
private void SwapColumnOrders(ColumnSettingsViewModel vm, int targetOrder) { // Get the column with targetOrder var col = Settings.FirstOrDefault(x => x.Order == targetOrder); if (col == null) return; var tmp = col.Order; col.Order = vm.Order; vm.Order = tmp; SettingsView.Refresh(); }