wpf-devexpress-dot-xpf-dot-editors-f8b02c14.md
Represents a color editor displayed within a drop-down window.
Namespace : DevExpress.Xpf.Editors
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
[DXLicenseWpfEditors]
public class PopupColorEdit :
PopupBaseEdit,
IColorEdit
<DXLicenseWpfEditors>
Public Class PopupColorEdit
Inherits PopupBaseEdit
Implements IColorEdit
The following members return PopupColorEdit objects:
The PopupColorEdit editor allows users to choose a color using a Color Picker interface in a drop-down window.
Tip
The PopupColorEdit class inherits its features from the PopupBaseEdit class.
Refer to the PopupBaseEdit class description for information on derived features and API.
To add a PopupColorEdit to a Window, drag it from the Toolbox.
The following sample demonstrates how to create a PopupColorEdit using XAML markup.
<dxe:PopupColorEdit ColumnCount="10" ShowNoColorButton="True"
DefaultColor="Crimson" NoColorButtonContent="Empty Color"
MoreColorsButtonContent="Color picker" ChipSize="Medium"/>
You can specify the editor’s value using the Color property.
<Window ...
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
<!-- Specify value using the PopupColorEdit.Color property -->
<dxe:PopupColorEdit Color="#ff396ba7"/>
To respond to changing the editor’s value, handle the BaseEdit.EditValueChanged event. To check the new value’s validity, handle the BaseEdit.Validate event.
You can create gradient palettes from predefined sets of colors.
myPopupColorEdit.Palettes.Add(
CustomPalette.CreateGradientPalette(
"Verve",
PredefinedColorCollections.Verve
)
);
You can define your own color sets:
using DevExpress.Xpf.Editors;
...
List<Color> customColors = new List() {
Color.FromRgb(170, 0, 0),
Color.FromRgb(0, 125, 0),
Color.FromRgb(0, 0, 170) };
myPopupColorEdit.Palettes.Add(new CustomPalette("Custom RGB Colors", customColors));
The PopupColorEdit.ShowMoreColorsButton property controls the availability of the More Colors button. Clicking this button invokes the built-in color picker tool. Color picker allows end-users to select the desired color visually or by specifying the precise values.
You can specify the number of color columns in each palette using the PopupColorEdit.ColumnCount property. The PopupColorEdit.ChipSize property controls the size of the color chips.
You can define the default color using the PopupColorEdit.DefaultColor property. The PopupColorEdit.ShowDefaultColorButton property toggles the availability of the Default Color button.
Setting the PopupColorEdit.ShowNoColorButton property to true enables the No Color button. The No Color button allows users to select an empty color.
This example shows how to create custom palettes and display them within the PopupColorEdit control.
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports DevExpress.Xpf.Editors
Namespace DXEditors_PopupColorEdit
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
' Removes the 'Standard Colors' palette.
popupColorEdit1.Palettes.Remove(popupColorEdit1.Palettes("Standard Colors"))
' Adds a custom gradient palette.
popupColorEdit1.Palettes.Add(CustomPalette.CreateGradientPalette("Apex Colors", PredefinedColorCollections.Apex))
' Adds a new palette with three custom RGB colors.
Dim customColors As List(Of Color) = New List(Of Color)
customColors.Add(Color.FromRgb(150, 18, 30))
customColors.Add(Color.FromRgb(20, 40, 20))
customColors.Add(Color.FromRgb(88, 73, 29))
Dim palette As CustomPalette = New CustomPalette("Custom RGB Colors", customColors)
popupColorEdit1.Palettes.Add(palette)
End Sub
End Class
End Namespace
<Window x:Class="DXEditors_PopupColorEdit.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/core">
<Grid>
<Grid.Resources>
<ResourceDictionary>
<dxc:ColorToBrushConverter x:Key="ColorToBrushConverter" />
</ResourceDictionary>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<GroupBox Header="Text Color" Grid.Row="0" HorizontalAlignment="Left" Margin="3" Name="groupBox1" VerticalAlignment="Top">
<Grid>
<dxe:PopupColorEdit Name="popupColorEdit1" Color="Green" Width="130" />
</Grid>
</GroupBox>
<GroupBox HorizontalAlignment="Stretch" Header="Text Box" Grid.Row="1" Margin="3" Name="groupBox2" VerticalAlignment="Stretch">
<Grid>
<TextBox Text="Sample text..." Grid.Column="1" Foreground="{Binding Path=Color, ElementName=popupColorEdit1, Converter={StaticResource ColorToBrushConverter}}" Margin="3" Name="textBox1" />
</Grid>
</GroupBox>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Editors;
namespace DXEditors_PopupColorEdit {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
// Removes the 'Standard Colors' palette.
popupColorEdit1.Palettes.Remove(popupColorEdit1.Palettes["Standard Colors"]);
// Adds a custom gradient palette.
popupColorEdit1.Palettes.Add(CustomPalette.CreateGradientPalette("Apex Colors", PredefinedColorCollections.Apex));
// Adds a new palette with three custom RGB colors.
popupColorEdit1.Palettes.Add(
new CustomPalette("Custom RGB Colors",
new List<Color>() {
Color.FromRgb(150, 18, 30),
Color.FromRgb(20, 40, 20),
Color.FromRgb(88, 73, 29) }));
}
}
}
The following code snippets (auto-collected from DevExpress Examples) contain references to the PopupColorEdit class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
<WrapPanel Grid.Row="0">
<dxe:PopupColorEdit
Height="Auto"
wpf-themes-use-palette-resources-in-custom-controls/CS/DXSample/MainWindow.xaml#L24
<local:CustomControl1 Margin="5" Text="Custom control with a style that uses palette resources." />
<dxe:PopupColorEdit EditValue="{LWThemeValue Default=Color.Custom.Red, Win11=Color.Custom.Green, TargetType=Color}" />
</StackPanel>
Show 13 items
Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control BaseEdit TextEditBase TextEdit ButtonEdit PopupBaseEdit PopupColorEdit
See Also