c# - 无法在 ControlTemplate 中引用控件

标签 c# wpf controls controltemplate

我有一个 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.

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

最佳答案

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

关于c# - 无法在 ControlTemplate 中引用控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4449132/

相关文章:

C# 赋予控件数组属性

delphi - 如何检测 float 控件是否关闭?

c# - 为什么这个变量得不到正确的值?

c# - 如何通过 PID 向 CMD 进程发送关闭命令

c# - 无法在程序中打开sqlite数据库文件

ios - 处理 DPad 和 Shooting Swift 的多次触摸

c# - Visual Studio 2008 构建失败,没有错误输出

.net - 绑定(bind)到数组元素

c# - WPF Datagrid 上的选定行 LostFocus mvvm 模式

c# - 如何创建和实现自定义命令?