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; // for PrppertyInfo using System.Reflection; namespace WpfResourcesApp2C { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private Color color; SolidColorBrush colorBrush = new SolidColorBrush(); public MainWindow() { InitializeComponent(); Type colorType = typeof(Colors); foreach (PropertyInfo property in colorType.GetProperties()) { listBox1.Items.Add(property.Name); color = Colors.Azure; listBox1.Background = Brushes.Beige; this.Background = Brushes.BlanchedAlmond; } } private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { string str1 = listBox1.SelectedItem.ToString(); color = (Color)ColorConverter.ConvertFromString(str1); textBox1.Text += color; canvas1.Background = new SolidColorBrush(color); } } }