private void CustomItem_PaletteItemCustomColorChanged(ColorPaletteSelectorItem source) { if (source.IsCustom) { CustomValue = source.Color; Value = source.Color; } }
private void PaletteItem_PaletteItemClicked(ColorPaletteSelectorItem source) { Value = source.Color; }
private void RebuildPaletteList() { if (_paletteList != null) { foreach (var paletteItem in _paletteList) { paletteItem.PaletteItemClicked -= PaletteItem_PaletteItemClicked; paletteItem.PaletteItemCustomColorChanged -= CustomItem_PaletteItemCustomColorChanged; } } var allowCustom = AllowCustomColor; var sourcePalette = PaletteColors; var customValue = CustomValue; var value = Value; if (sourcePalette == null || sourcePalette.Count == 0) { if (allowCustom) { _paletteList = new List <ColorPaletteSelectorItem>(1); } else { _paletteList = null; } } else { if (allowCustom) { _paletteList = new List <ColorPaletteSelectorItem>(sourcePalette.Count + 1); } else { _paletteList = new List <ColorPaletteSelectorItem>(sourcePalette.Count); } } if (sourcePalette != null) { foreach (var c in sourcePalette) { _paletteList.Add(new ColorPaletteSelectorItem(c, null, null, c == value, false)); } } if (allowCustom) { var customItem = new ColorPaletteSelectorItem(customValue, null, "\uE790", customValue == value, true); customItem.PaletteItemCustomColorChanged += CustomItem_PaletteItemCustomColorChanged; _paletteList.Add(customItem); } if (_paletteList != null) { foreach (var paletteItem in _paletteList) { paletteItem.PaletteItemClicked += PaletteItem_PaletteItemClicked; } } PaletteItemsContainer.ItemsSource = _paletteList; }