views:

52

answers:

1

I need to an extra dependancy property to a control, so I'm overriding it. I.E.:

namespace Custom_TextBlock_Sample
{
  public class CustomLabel: Label
  {

  }
}

But I seem to be unable to add it to a DataTemplate. The following code will fail to build:

 ... xmlns:Custom_TextBlock_Sample="clr-namespace:Custom_TextBlock_Sample" ...

   <DataTemplate x:Key="Test">
      <Grid>
        <Custom_TextBlock_Sample:CustomLabel></Custom_TextBlock_Sample:CustomLabel>
      </Grid>
    </DataTemplate>

However inserting my overriden control anywhere else, (say not in the datatemplate) .. and compilation works no problem.

The following works: (My control is not nested in a date template).

  <Grid>
      <Custom_TextBlock_Sample:CustomLabel></Custom_TextBlock_Sample:CustomLabel>
  </Grid>

Also using a regular label in the Datatemplate also works:

<DataTemplate x:Key="Test">
  <Grid>
    <Label/>
  </Grid>
</DataTemplate>

Any ideas on what the issue might be ? Can I simply not add overridden controls to datatemplates in such a manor ? Is this a bug in Visual Studio 2007?

Note that since my intended changed to the control will be small, I simply want to override "Label" instead of wrapping it in a UserControl.

Thanks

A: 

Ok, figured it out. This seems to be a namespace bug with Visual Studio. The problem fixed itself, when I started a new project from scratch, this time with no spaces in the project name and no "_" in namespaces names.

vicjugador