protected virtual void ClearValueCore(DependencyProperty dp)
 {
     if (_LocalValue.ContainsKey(dp))
     {
         object oldValue = _LocalValue[dp];
         _LocalValue.Remove(dp);
         if (oldValue != dp.DefaultMetadata.DefaultValue && dp.DefaultMetadata.PropertyChangedCallback != null)
         {
             DependencyPropertyChangedEventArgs e = new DependencyPropertyChangedEventArgs(dp, oldValue, dp.DefaultMetadata.DefaultValue);
             dp.DefaultMetadata.PropertyChangedCallback(this, e);
         }
     }
 }
 protected virtual void SetValueCore(DependencyProperty dp, object value)
 {
     if (dp.ValidateValueCallback != null)
         if (!dp.ValidateValueCallback(value))
             throw new ArgumentException("Value invalid.");
     if (dp.DefaultMetadata.CoerceValueCallback != null)
         value = dp.DefaultMetadata.CoerceValueCallback(this, value);
     object oldValue;
     if (_LocalValue.ContainsKey(dp))
     {
         oldValue = _LocalValue[dp];
         _LocalValue[dp] = value;
     }
     else
     {
         oldValue = dp.DefaultMetadata.DefaultValue;
         _LocalValue.Add(dp, value);
     }
     if (dp.DefaultMetadata.PropertyChangedCallback != null)
     {
         DependencyPropertyChangedEventArgs e = new DependencyPropertyChangedEventArgs(dp, oldValue, value);
         dp.DefaultMetadata.PropertyChangedCallback(this, e);
     }
 }