void PossiblyNameChanged(XamlPropertyValue oldValue, XamlPropertyValue newValue) { if (ParentObject.RuntimeNameProperty != null && PropertyName == ParentObject.RuntimeNameProperty) { if (!String.IsNullOrEmpty(ParentObject.GetXamlAttribute("Name"))) { throw new XamlLoadException("The property 'Name' is set more than once."); } string oldName = null; string newName = null; var oldTextValue = oldValue as XamlTextValue; if (oldTextValue != null) { oldName = oldTextValue.Text; } var newTextValue = newValue as XamlTextValue; if (newTextValue != null) { newName = newTextValue.Text; } NameScopeHelper.NameChanged(ParentObject, oldName, newName); } }