ColorPicker

Color selection with palette grid, hex entry, and preview swatch.

Overview

ColorPicker extends Control and provides an interactive color selection experience within the terminal. The control displays a 16-color palette grid arranged in 2 rows of 8 columns, a preview swatch showing the currently selected color, and a hex value display. Users navigate the palette with arrow keys and press Enter to select a color, or type hex digits (0–9, A–F) directly for precise color entry. The hex input buffer is shown in real time and committed on Enter. Backspace removes the last hex digit, and Escape cancels the current hex input, reverting to the palette selection.

Basic Example

<StackPanel Orientation="Vertical">
  <TextBlock Text="Pick a color:" />
  <ColorPicker />
</StackPanel>

Properties

PropertyTypeDefaultDescription
SelectedColorColorWhiteThe currently selected color value.
FocusColorColorCyanBorder color when the control has keyboard focus.
HoverColorColorYellowBorder color when the mouse hovers over the control.
WidthSizeAutoExplicit width of the control.
HeightSizeAutoExplicit height of the control.

Events

EventTypeDescription
SelectedColorChangedEventHandler<Color>Raised when the selected color changes, either through palette navigation or hex entry.

Examples

Basic Color Picker

<StackPanel Orientation="Vertical">
  <TextBlock Text="Theme color:" />
  <ColorPicker />
</StackPanel>

Pre-Set Color

<StackPanel Orientation="Vertical">
  <TextBlock Text="Background color:" />
  <ColorPicker SelectedColor="Blue"
               FocusColor="Green" />
</StackPanel>

With Data Binding

<StackPanel Orientation="Vertical">
  <TextBlock Text="Accent color:" />
  <ColorPicker SelectedColor="{Binding AccentColor, Mode=TwoWay}" />
  <TextBlock Text="Preview:"
             Foreground="{Binding AccentColor}" />
</StackPanel>

Keyboard Shortcuts

KeyAction
Left ArrowMove to the previous color in the palette grid.
Right ArrowMove to the next color in the palette grid.
Up ArrowMove to the color above in the palette grid.
Down ArrowMove to the color below in the palette grid.
Enter / SpaceSelect the currently highlighted palette color.
0–9, A–FDirect hex entry — appends to the hex input buffer.
BackspaceDelete the last hex digit from the input buffer.
EscapeCancel the current hex input and return to palette selection.

Key Concepts