In This Article

BrushPicker

The BrushPicker control makes it easy for end users to select a Brush via touch or a mouse. It is generally intended for display within a popup, such as for the BrushEditBox control.

Screenshot

It combines a horizontal list for picking the brush kind, along with ColorPicker and GradientStopSlider controls for modifying the brush value.

Alpha transparency and gradients are also optionally supported.

Alpha Transparency

The BrushPicker.IsAlphaEnabled property governs whether alpha transparency is supported.

When false, the edit box will only allow selection of RGB colors instead of ARGB colors.

Gradient Support

The BrushPicker.IsGradientAllowed property can be set to false to prevent gradient brushes from being supported.

When false, the picker will hide all brush kind options related to gradients.

Null Support

The BrushPicker.IsNullAllowed property can be set to false to always require that a valid Brush value is present, and that null is not supported.

When false, the picker will hide the null brush kind option.

Reusing Brushes

By default, the brush instance will generally be reused when a component like gradient stop is updated. But this prevents the ValueChanged event from firing on certain component changes, and also bindings to the Value property from updating when using value converters. The CanReuseBrush property can be set to false to force a new brush to be created any time a component is updated, which works around those issues.

Sample XAML

This control can be placed within any other XAML container control, such as a Page or Panel with this sort of XAML:

<editors:BrushPicker Value="{Binding Path=YourVMProperty, Mode=TwoWay}" />