public ListColorsElegantly() { Title = "List Colors Elegantly"; ColorListBox lstbox = new ColorListBox(); lstbox.Height = 150; lstbox.Width = 150; lstbox.SelectionChanged += ListBoxOnSelectionChanged; Content = lstbox; lstbox.SelectedColor = SystemColors.WindowColor; }
void ListBoxOnSelectionChanged(object sender, SelectionChangedEventArgs args) { ColorListBox lstbox = sender as ColorListBox; Background = new SolidColorBrush(lstbox.SelectedColor); }