0

在 VisualStudio 2008 中,设计界面只是空的,因为我将此样式添加到 App.xaml:

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

并在顶部添加此必需的命名空间以使数据:可解析

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

运行 Silverlight 应用程序时,一切正常。然而,设计表面是空的,我在编辑 xaml 时出现了这个错误:

属性值数据无效:属性 TargetType 的 DataGridCell

如前所述,这个错误只是在设计时发生的。编译工作完美。我在做什么错,为什么设计者不能正确解析这个命名空间?

更新:此外,当我将样式从 App.xaml 移动到 Page.xaml 时,设计师再次工作。有什么想法吗?

4

3 回答 3

0

你试过这个吗?

<Style x:Key="RightAlignedCell" TargetType="{x:Type data:DataGridCell}">
    <Style.Setters>
        <Setter Property="HorizontalContentAlignment" Value="Right" />
    </Style.Setters>
</Style>
于 2009-02-26T09:23:53.037 回答
0

将 xmlns 声明移动到资源字典。像这样: <ResourceDictionary xmlns:myconverters="clr-namespace:MyCustomConverters;assembly=MyCustomConverters"> ... </ResourceDictionary>

示例可以在这里找到:blog.andrew-veresov.com/post/Silverlight-20-usage-of-the-converters-from-external-assembly-in-appxaml.aspx

于 2009-06-01T09:41:59.397 回答
0

根据 MS silverlight FAQ,这似乎是一个已知错误,无法修复。

于 2009-03-25T12:46:16.567 回答