【问题标题】:Broken Silverlight Design-Surface in VS2008VS2008 中损坏的 Silverlight 设计-Surface
【发布时间】:2009-02-26 09:15:38
【问题描述】:

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

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

并在顶部添加这个必需的命名空间以使 data: 可解析

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

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

无效的属性值 数据:DataGridCell 用于属性 目标类型

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

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

【问题讨论】:

    标签: silverlight namespaces app.xaml design-surface


    【解决方案1】:

    你试过这个吗?

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

    【讨论】:

    • 这会导致错误“属性 TargetType 的属性值 {x:Type data:DataGridCell} 无效。”
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      将 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-02
        • 1970-01-01
        • 2019-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-07
        相关资源
        最近更新 更多