override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // Get a reference to the templated parts
            _image = GetTemplateChild("Image") as Image;
            if (_image == null)
            {
                throw new Exception("Missing 'Image' Template part.");
            }

            // Initialize default swatch dpi with the view dpi
            _swatchDpi = CompatUtility.IsDesignMode ? 96.0 : CompatUtility.LogicalDpi(this);
        }
 private void OnSwatchDpiChanged(double newValue)
 {
     _swatchDpi = newValue > 0.0 ? newValue : CompatUtility.LogicalDpi(this);
     SetDirty();
 }