private void SetAttachedProperty(object value, AttachedPropertyInfo attachedProperty, SurfacePair pair) { var set = value; if (set != null && (value.Equals("NULL") || value.Equals("null"))) { set = null; } if (set != null) { set = Convert.ChangeType(value, attachedProperty?.GetMethod.ReturnType); } try { attachedProperty?.SetMethod.Invoke(null, new[] { pair.VisualElement, set }); } catch (ArgumentException) { // ignored for now; this should be logged and the user should be notified with a validation message } catch (Exception) { // ignored for now; this should be logged and the user should be notified with a validation message } }
/// <summary> /// Attach the child to the parent object. /// </summary> /// <param name="child"></param> /// <param name="parent"></param> /// <returns> /// Returns true if the view was attached to the parent; otherwise, false. /// </returns> public abstract bool SetParent(Element child, SurfacePair parent);