Exemplo n.º 1
0
        protected override void OnDispose()
        {
            if (this.Value is SolidColorBrush && colorCanvas != null)
            {
                TargetDependencyProperty.RemoveValueChanged(Target, Brush_Changed);
                colorCanvas.SelectedColorChanged -= ColorCanvas_SelectedColorChanged;

                colorCanvas = null;
            }
        }
Exemplo n.º 2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            colorCanvas = GetTemplateChild <ColorCanvas>("PART_colorCanvas");

            if (this.Value is SolidColorBrush brush)
            {
                colorCanvas.SelectedColor = brush.Color;

                TargetDependencyProperty.AddValueChanged(Target, Brush_Changed);
                colorCanvas.SelectedColorChanged += ColorCanvas_SelectedColorChanged;
            }
            else
            {
                this.IsEnabled = false;
            }
        }