【问题标题】:Can't reference a control inside ControlTemplate无法引用 ControlTemplate 中的控件
【发布时间】:2010-12-15 10:56:17
【问题描述】:

我有一个 ResourceDictionary,其中包含一个 ControlTemplate,我在其中引用来自另一个程序集的对象。

<ResourceDictionary
    xmlns:gauge="clr-namespace:ActiproSoftware.Products.Gauge;assembly=ActiproSoftware.Gauge.Wpf351">

    <ControlTemplate x:Key="Gauge270Template">
        <gauge:CircularGauge/>
    </ControlTemplate>
</ResourceDictionary>

这给了我以下错误:

Error   1   The type 'gauge:CircularGauge' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

附:仪表组件已构建,我可以从应用程序的其他部分引用它

【问题讨论】:

  • 我无法重现这个。您的代码看起来也很好,很难说出问题所在。当您键入 <... resourcedictionary>

标签: c# wpf controls controltemplate


【解决方案1】:

确保这两个程序集都不以项目属性的“构建”部分中的客户端配置文件为目标。可能引用 Gauge 控件的程序集设置为目标 .Net Framework 4.0 客户端配置文件(VS 2010 的默认设置)(您还可以在构建错误的警告部分中看到此问题)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-07
    • 2010-12-06
    • 1970-01-01
    相关资源
    最近更新 更多