private void UpdateColorPaletteFromGrid() { if (_currentColorPalette == null) { throw new Exception("No ColorPalette selected."); } var newColors = new GlyphColor[ColorGrid.ColumnCount, ColorGrid.RowCount]; // fill with patches in Grid foreach (var colorPatch in ColorGrid.ColorPatches) { newColors[colorPatch.GridLocation.X, colorPatch.GridLocation.Y] = colorPatch.Color.ToGlyphColor(); } _currentColorPalette.ChangeColors(newColors); }