views:

261

answers:

3

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?

A: 

Have you tried this one?

<Style x:Key="RightAlignedCell" TargetType="{x:Type data:DataGridCell}">
    <Style.Setters>
        <Setter Property="HorizontalContentAlignment" Value="Right" />
    </Style.Setters>
</Style>
Franci Penov
This causes the error "Invalid attribute value {x:Type data:DataGridCell} for property TargetType."
driAn
A: 

This seems to be a known bug according to the MS silverlight FAQ, no way to fix this.

driAn
A: 

Move xmlns declaration to resource dictionary. Like this: <ResourceDictionary xmlns:myconverters="clr-namespace:MyCustomConverters;assembly=MyCustomConverters"> ... </ResourceDictionary>

Example could be found here: blog.andrew-veresov.com/post/Silverlight-20-usage-of-the-converters-from-external-assembly-in-appxaml.aspx