This code is used for Windows applications. Cannot be used in WPF windows :-
private void part1colorbtn_Click(object sender, RoutedEventArgs e)
{
DialogResult result = colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
part2colorbtn.BackColor = colorDialog1.Color;
}
}
How to use color dialog box inside WPF windows? Please help me.

Amit MohantyRank #112 · 20K reputationPosted Jan 12, 2023, 5:40 AM EST
Try this
private void Button_Click(object sender, RoutedEventArgs e) { // Create a new instance of the ColorDialog var colorDialog = new ColorDialog(); // Show the color dialog if (colorDialog.ShowDialog() == DialogResult.OK) { // Update the color of the button var selectedColor = colorDialog.Color; part2colorbtn.Background = new SolidColorBrush(Color.FromArgb(selectedColor.A, selectedColor.R, selectedColor.G, selectedColor.B)); } }Vikas PanwarRank #1,447 · 1.1K reputationPosted Jan 12, 2023, 8:31 AM EST
Try this for more information.
https://www.c-sharpcorner.com/UploadFile/87b416/create-color-picker-in-wpf/
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jan 12, 2023, 11:48 AM EST
Refer below articles
https://www.c-sharpcorner.com/UploadFile/mahesh/wpf-colorpicker/
https://www.c-sharpcorner.com/blogs/wpf-color-picker-c-sharp