private static void EnsureCoercionDataForProperty(DependencyObject d, DependencyProperty dp, object defaultBaseValue, out CoercionData cd, out CoercedPropertyInfo cpi) { cd = GetCoercionData(d); cpi = null; if (cd == null) { cd = new CoercionData(); SetCoercionData(d, cd); } else { cd.TryGetValue(dp, out cpi); } if (cpi == null) { cpi = new CoercedPropertyInfo(); cpi.BaseValue = defaultBaseValue; cd[dp] = cpi; } }
/// <summary> /// Sets the CoercionData property. This dependency property /// is attached to any dependency object that contains coerced property values. /// </summary> private static void SetCoercionData(DependencyObject d, CoercionData value) { d.SetValue(CoercionDataProperty, value); }