R – Broken Silverlight Design-Surface in VS2008

app.xamldesign-surfacenamespacessilverlight

In VisualStudio 2008, the design surface is just empty since I added this style to App.xaml:

    <Style x:Key="RightAlignedCell" TargetType="data:DataGridCell">
        <Style.Setters>
            <Setter Property="HorizontalContentAlignment" Value="Right" />
        </Style.Setters>
    </Style>

and adding this required namespace at the top to make data: resolveable

xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"

When running the Silverlight app, everything works fine. However the design surface is empty and I get this error showing up while editing the xaml:

Invalid attribute value
data:DataGridCell for property
TargetType

As said, this error is just something that happens during design-time. The compilation works just perfect. What am I doing wrong, why can't the designer properly resolve this namespace?

Update: Also when I move the style from App.xaml to Page.xaml, the designer works again.. Any ideas?

Best Answer

Have you tried this one?

<Style x:Key="RightAlignedCell" TargetType="{x:Type data:DataGridCell}">
    <Style.Setters>
        <Setter Property="HorizontalContentAlignment" Value="Right" />
    </Style.Setters>
</Style>