views:

15

answers:

0

I have and issue with using the XmlnsDefinition attribute within a silverlight 4 assembly.

Here's the test case:

In AssemblyInfo.cs of the silverlight project I add the following:

[assembly: XmlnsDefinition("urn:foo", "SilverlightApplication1")]
[assembly: XmlnsDefinition("urn:foo", "SilverlightApplication1.SomeNamespace")]

I edit MainPage.xaml.cs and to make it look like so:

namespace SilverlightApplication1
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
    }
}

namespace SilverlightApplication1.SomeNamespace
{
    public class SomeControl : ContentControl
    {
    }
}

Now in MainPage.xaml I have the following:

<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
    xmlns:foo="urn:foo">

    <Grid>
        <foo:SomeControl>
            <TextBlock Text="Hello World"/>
        </foo:SomeControl>
    </Grid>

</UserControl>

This compiles and runs fine. The problem occurs when I add the x:Name attribute to the SomeControl tag.

This does not compile:

<foo:SomeControl x:Name="bar">
    <TextBlock Text="Hello World"/>
</foo:SomeControl>

Looking at the .g.i.cs file that gets generated, the control is declared as

internal SomeControl bar;

The file is missing either the using statement or the full type name. I've also tried this in WPF and the results are the same. Can anyone tell me what, if anything, I'm doing wrong?