<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1">
<Grid>
<local:ElementType x:Name="FirstElementName">
<local:ElementType x:Name="SecondElementName" Grid.Column="1" Grid.Row="1" />
</local:ElementType>
</Grid>
</Window>
And this is in other files ...
<Grid x:Name="InternalElementName" x:Class="WpfApplication1.ElementType"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1">
</Grid>
And ...
public partial class ElementType : System.Windows.Controls.Grid { }
Everything works fine, except the second element.
I get the error:
Cannot set Name attribute value 'SecondElementName' on element 'ElementType'. 'ElementType' is under the scope of element 'ElementType', which already had a name registered when it was defined in another scope.
The custom grids are defined properly. The code will compile and run if I take out the property ---
x:Name="SecondElementName"
--- in Window1.xaml
What is causing this error? How do I get around it? I need to nest one of these custom grids inside the other one, and I need names on both of them so I can bind them to seperate data.
Thanks in advance.