public override void OnApplyTemplate() { if (PointThickness != null) PointThickness.ThicknessValueChanged -= PointThickness_ThicknessValueChanged; if (SymbolBorderThickness != null) SymbolBorderThickness.ThicknessValueChanged -= SymbolBorderThickness_ThicknessValueChanged; if (OutlineColorSelector != null) OutlineColorSelector.ColorPicked -= OutlineColorSelector_ColorPicked; if (SymbolPicker != null) { SymbolPicker.CollapseDropDown(); SymbolPicker.SymbolSelected -= SymbolPicker_SymbolSelected; } if(OpacitySlider != null) OpacitySlider.ValueChanged -= OpacitySlider_ValueChanged; if (BorderOpacitySlider != null) BorderOpacitySlider.ValueChanged -= BorderOpacitySlider_ValueChanged; base.OnApplyTemplate(); SymbolPicker = GetTemplateChild(PART_SYMBOLPICKER) as SymbolPicker; if(SymbolPicker != null) SymbolPicker.SymbolSelected += SymbolPicker_SymbolSelected; PointThickness = GetTemplateChild(PART_POINTTHICKNESS) as ThicknessUpDownControl; if(PointThickness != null) PointThickness.ThicknessValueChanged += PointThickness_ThicknessValueChanged; SymbolBorderThickness = GetTemplateChild(PART_SYMBOLBORDERTHICKNESS) as ThicknessUpDownControl; if (SymbolBorderThickness != null) SymbolBorderThickness.ThicknessValueChanged += SymbolBorderThickness_ThicknessValueChanged; OutlineColorSelector = GetTemplateChild(PART_OUTLINECOLORSELECTOR) as SolidColorBrushSelector; if(OutlineColorSelector != null) OutlineColorSelector.ColorPicked += OutlineColorSelector_ColorPicked; FillColorSelector = GetTemplateChild(PART_FILLCOLORSELECTOR) as SolidColorBrushSelector; if(FillColorSelector != null) FillColorSelector.ColorPicked += FillColorSelector_ColorPicked; OpacitySlider = GetTemplateChild(PART_OPACITYSLIDER) as Slider; if (OpacitySlider != null) OpacitySlider.ValueChanged += OpacitySlider_ValueChanged; BorderOpacitySlider = GetTemplateChild(PART_BORDEROPACITYSLIDER) as Slider; if(BorderOpacitySlider != null) BorderOpacitySlider.ValueChanged += BorderOpacitySlider_ValueChanged; bindUIToSymbol(); if (InitCompleted != null) InitCompleted(this, EventArgs.Empty); }