public static DependencyProperty Register(string name, Type properType, Type ownerType, object defaultValue) { DependencyProperty dp = new DependencyProperty(name, properType, ownerType, defaultValue) { Index = ++ globalIndex }; RegisteredDps.Add(dp.HashCode, dp); return dp; }
public void SetValue(DependencyProperty dp, object value) { EffectiveValueEntry effectiveValue = _effectiveValueEntries.FirstOrDefault((i) => i.PropertyIndex == dp.Index); if (effectiveValue != null && effectiveValue.PropertyIndex != 0) effectiveValue.Value = value; else { effectiveValue = new EffectiveValueEntry() {PropertyIndex = dp.Index, Value = value}; _effectiveValueEntries.Add(effectiveValue); //DependencyProperty.RegisteredDps[dp.HashCode].Value = value; } }
public object GetValue(DependencyProperty dp) { EffectiveValueEntry effectiveValue = _effectiveValueEntries.FirstOrDefault((i) => i.PropertyIndex == dp.Index); if (effectiveValue != null && effectiveValue.PropertyIndex != 0) { return effectiveValue.Value; } PorpertypeMetadata metadata = DependencyProperty.RegisteredDps[dp.HashCode].GetMetadata(this.GetType()); return metadata.Value; }