/// <summary>
        /// Gets the current value of the property for the object
        /// </summary>
        /// <returns>
        /// Returns an object or null
        /// </returns>
        /// <param name='instance'>
        /// The object to look up in the values dictionary
        /// </param>
        /// <param name='property'>
        /// The property describing the value to look up.
        /// </param>
        /// <param name='addIfMissing'>Adds a reference if not found</param>
        private static KeyValueWeakReference GetCurrent(object instance, AttachedProperty property, bool addIfMissing)
        {
            KeyValueWeakReference result = null;

            if (ValueDictionary.ContainsKey(instance))
            {
                var values = ValueDictionary[instance];
                result = values.FirstOrDefault(x => x.Target == instance && x.Key == property.PropertyKey);

                if (result == null && addIfMissing)
                {
                    result = new KeyValueWeakReference(instance, property.PropertyKey);
                    values.Add(result);
                }

                return(result);
            }

            if (addIfMissing)
            {
                result = new KeyValueWeakReference(instance, property.PropertyKey);
                ValueDictionary.Add(instance, new List <KeyValueWeakReference>()
                {
                    result
                });
            }

            return(result);
        }
 /// <summary>
 /// Gets the current value of the property for the object
 /// </summary>
 /// <returns>
 /// Returns an object or null
 /// </returns>
 /// <param name='instance'>
 /// The object to look up in the values dictionary
 /// </param>
 /// <param name='property'>
 /// The property describing the value to look up.
 /// </param>
 /// <param name='addIfMissing'>Adds a reference if not found</param>
 private static KeyValueWeakReference GetCurrent(object instance, AttachedProperty property, bool addIfMissing)
 {
     KeyValueWeakReference result = null;
     
     if (ValueDictionary.ContainsKey(instance))
     {
         var values = ValueDictionary[instance];
         result = values.FirstOrDefault(x => x.Target == instance && x.Key == property.PropertyKey);
         
         if (result == null && addIfMissing)
         {
             result = new KeyValueWeakReference(instance, property.PropertyKey);
             values.Add(result);
         }
         
         return result;
     }
     
     if (addIfMissing)
     {
         result = new KeyValueWeakReference(instance, property.PropertyKey);
         ValueDictionary.Add(instance, new List<KeyValueWeakReference>() { result });
     }
     
     return result;
 }