private static void onColorChange(DependencyObject d, DependencyPropertyChangedEventArgs e) { CustomColorPicker me = d as CustomColorPicker; if (me != null && e.OldValue != e.NewValue) { me.recContent.Fill = new SolidColorBrush((Color)e.NewValue); } }
private UIElement createColorPicker(int marginTop, string propName,object color) { Brush brush = null; try { brush = (Brush)color; } catch (Exception e) { } CustomColorPicker customColorPicker = new CustomColorPicker(); customColorPicker.Margin = new Thickness(0, marginTop, 0, 0); customColorPicker.Height = 28; customColorPicker.HorizontalAlignment = HorizontalAlignment.Left; customColorPicker.Name = propName + "textBox"; customColorPicker.VerticalAlignment = VerticalAlignment.Top; customColorPicker.Width = 120; if (brush != null) { customColorPicker.updateDisplayColor(brush); //customColorPicker.SelectedColor = ((SolidColorBrush)brush).Color; } Binding binding = new Binding(propName); binding.Source = WhatsappProperties.Instance; binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; customColorPicker.SetBinding(CustomColorPicker.SelectedColorBrushProperty, binding); BindingExpression be = customColorPicker.GetBindingExpression(CustomColorPicker.SelectedColorBrushProperty); BindingExpressions.Add(be); return customColorPicker; }