// ******************************************************************** // Event Handlers // ******************************************************************** #region Event Handlers /// <summary> /// Handles when the Color property is changed /// </summary> /// <param name="dependency"></param> /// <param name="e"></param> protected static void UpdateColor(DependencyObject dependency, DependencyPropertyChangedEventArgs e) { ColorLabel colorLabel = (ColorLabel)dependency; Color newColor = (Color)e.NewValue; colorLabel.color.Fill = new SolidColorBrush(newColor); }
/// <summary> /// Handles when the Text property is changed /// </summary> /// <param name="dependency"></param> /// <param name="e"></param> protected static void UpdateText(DependencyObject dependency, DependencyPropertyChangedEventArgs e) { ColorLabel colorLabel = (ColorLabel)dependency; colorLabel.textBlock.Text = (string)e.NewValue; colorLabel.textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); colorLabel.color.Width = colorLabel.textBlock.DesiredSize.Height; }