Silverlight 4 has a very similar error. If you create user controls, usually:
<UserControl xmlns:MyNameSpace="clr-namespace:MyNameSpace" x:Class="MyNameSpace.MyClass" x:Name="userControl" ... />
Then, if you add 2 untitled controls to xaml code (with preview):
<MyNameSpace:MyClass ... /> <MyNameSpace:MyClass ... />
There will be an exception "Name already exists in the tree: userControl". This is because Silverlight cannot find the name (unnamed [MyClass]) and looks at UserControl, where it detects "userControl" twice.
One solution is to give some controls to the controls:
<MyNameSpace:MyClass x:Name = "MyControl1" ... />
Or initialize this control from code:
MyClass control = new MyClass(); SomeGrid.Children.Add(control);
source share