public override void OnApplyTemplate()
        {
            initializeBackgroundStart();
            initializeBackgroundEnd();
            initializeThemeColors();

             if (Palette != null)
                Palette.ColorPicked -= Palette_ColorPicked;
             if (Start != null)
                 Start.MouseLeftButtonUp -= Start_MouseLeftButtonUp;
             if (End != null)
                 End.MouseLeftButtonUp -= End_MouseLeftButtonUp;

            base.OnApplyTemplate();
            Palette = GetTemplateChild("Palette") as ColorPalette;
            if (Palette != null)
            {
                setupPalette();
                Palette.ColorPicked += new EventHandler<ColorChosenEventArgs>(Palette_ColorPicked);
                ApplyThemeColors();
            }

            Start = GetTemplateChild("Start") as Rectangle;
            if (Start != null)
                Start.MouseLeftButtonUp += Start_MouseLeftButtonUp;
            End = GetTemplateChild("End") as Rectangle;
            if (End != null)
                End.MouseLeftButtonUp += End_MouseLeftButtonUp;
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            initializeColorBrush();
            initializeThemeColors();

            if (ColorPalette != null)
                ColorPalette.ColorPicked -= ColorPalette_ColorPicked;

            ColorPalette = GetTemplateChild("ColorPalette") as ColorPalette;
            if (ColorPalette != null)
            {
                ColorPalette.ColorPicked += ColorPalette_ColorPicked;
                if (ColorBrush != null)
                    ColorPalette.SelectedColorBrush = ColorBrush;
            }

            if (DropDownButton != null)
            {
                DropDownButton.Opening -= DropDownButton_Opening;
                DropDownButton.PopupContent = null;
            }

            DropDownButton = GetTemplateChild("DropDownButton") as DropDownButton;
            if (DropDownButton != null)
            {
                DropDownButton.Opening += DropDownButton_Opening;
            }

            if (InitCompleted != null)
                InitCompleted(this, EventArgs.Empty);
        }
示例#3
0
        /// <summary>
        /// SelectedColorBrushProperty property changed handler.
        /// </summary>
        /// <param name="d">ColorPalette that changed its SelectedColorBrush.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnSelectedColorBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorPalette source = d as ColorPalette;

            source.OnSelectedColorBrushPropertyChanged();
        }