private void OnNewColorClicked(object sender, RoutedEventArgs args) { var button = (Button) sender; var colorList = (ColorItemList) button.DataContext; var cv = (CollectionView) CollectionViewSource.GetDefaultView(colorList); // add a new color based on the current one, then select the new one var newItem = new ColorItem((ColorItem) cv.CurrentItem); colorList.Add(newItem); cv.MoveCurrentTo(newItem); }
private void OnNewColorClicked(object sender, RoutedEventArgs args) { var button = (Button)sender; var colorList = (ColorItemList)button.DataContext; var cv = (CollectionView)CollectionViewSource.GetDefaultView(colorList); // add a new color based on the current one, then select the new one var newItem = new ColorItem((ColorItem)cv.CurrentItem); colorList.Add(newItem); cv.MoveCurrentTo(newItem); }
public ColorItem(ColorItem item) { Source = Sources.UserDefined; _name = "New Color"; _red = item._red; _green = item._green; _blue = item._blue; _hue = item._hue; _saturation = item._saturation; _value = item._value; _alpha = item._alpha; Luminance = item.Luminance; Brush = new SolidColorBrush(item.Brush.Color); }