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 System.Windows.Data; namespace WpfResourcesApp2B { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void ColorListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { string strColor; string str1; strColor = ColorListBox.SelectedValue.ToString(); // strColor = (ColorListBox.SelectedItem.ToString()); str1 = strColor; MessageBox.Show(str1); switch (str1) { case "#FFEOFFFF": button1.Background = Brushes.Red; canvas1.Background = Brushes.Red; break; case "#FFFOFFFF": button1.Background = Brushes.Azure; canvas1.Background = Brushes.Azure; break; case "#FFFO8080": button1.Background = Brushes.Orange; canvas1.Background = Brushes.Orange; break; case "#000000FF": button1.Background = Brushes.Transparent; canvas1.Background = Brushes.Transparent; break; case "#FFF5F5DC": button1.Background = Brushes.Beige; canvas1.Background = Brushes.Beige; break; case "#FF0000FF": button1.Background = Brushes.Blue; canvas1.Background = Brushes.Blue; break; } } } }