- Getting the correct namescope for RootItem (the INameScope case was not checked).
- Clears the local namescope for the object if it exists, otherwise name changes will be registered in the local namespace instead of RootItem document namespace.
- Only adds _Copy (or CopyX, where X is an integer) if the previous name did not already end with _Copy. This prevents names as "myname_Copy_Copy_Copy..." to occur when copying and pasting already copied elements.
- Registers the new name to the RootItem namescope, only setting site.Name is not enough as its not yet a part of the RootItem document namescope.
src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\XamlProperty.cs
Original author: Tobias Gummesson
------------------------------------------------------------------------------------------------------------------------
The previous solution regarding XAML names expected all properties of type string named Name to represent a name in XAML namescope, and this caused trouble with types with a property named Name that did not represent a XAML name. In this case the value of the property tried to be registered as name to the namescope and this caused either the value to be occupied as name, or threw an exception if name already was taken or the value consisted of characters forbidden in XAML names causing the value to not be set at all.
To solve this the value of a Name property is only registered to namescope if the property represents a XAML name (defined by RuntimeNamePropertyAttribute).
Also added a Name property to XamlObject that always sets the name to x:Name attribute, but gets it from either x:Name or the property that represents the XAML name if it exists (both are valid places for name registration).
Fixed a bug in XamlParser where x:Name value was not registered in its namescope.
All other changes (for example changes in PropertyGrid/XamlDesignItem) was to support the Name fixes described above.