private static void OnSelectedColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { ComboColorPicker cp = obj as ComboColorPicker; Debug.Assert(cp != null); Color newColor = (Color)args.NewValue; Color oldColor = (Color)args.OldValue; if (newColor == oldColor) { return; } // When the SelectedColor changes, set the selected value of the combo box ColorViewModel selectedColorViewModel = cp.ColorList1.SelectedValue as ColorViewModel; if (selectedColorViewModel == null || selectedColorViewModel.Color != newColor) { // Add the color if not found if (!cp.ListContains(newColor)) { cp.AddColor(newColor, newColor.ToString()); } } // Also update the brush cp.SelectedBrush = new SolidColorBrush(newColor); cp.OnColorChanged(oldColor, newColor); }
private static void OnSelectedBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // Debug.WriteLine("OnSelectedBrushChanged"); ComboColorPicker cp = (ComboColorPicker)obj; SolidColorBrush newBrush = (SolidColorBrush)args.NewValue; // SolidColorBrush oldBrush = (SolidColorBrush)args.OldValue; if (cp.SelectedColor != newBrush.Color) { cp.SelectedColor = newBrush.Color; } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.ThisColorPicker = ((OpenSourceControls.ComboColorPicker)(target)); return; case 2: this.ColorList1 = ((System.Windows.Controls.ComboBox)(target)); return; } this._contentLoaded = true; }