internal void RegisterNamedItem (XamlObjectElement element, string name)
{
IDictionary rd = CurrentDictionary (element);
if (rd != null && element.X_Key != null) {
throw ParseException ("The name already exists in the tree.");
}
if (element.X_Name != null) {
throw ParseException ("Cannot specify both Name and x:Name attributes.");
}
element.X_Name = name;
FrameworkElement fe = element.FrameworkElement;
if (fe != null)
fe.SetNameOnScope (name, NameScope);
}