【发布时间】:2012-09-24 16:58:04
【问题描述】:
我是 WPF 新手,我正在尝试解决一个错误。我正在尝试构建一个自定义控件库,我可以在其中制作自己的控件对象。当我转到文件 > 新项目 > WPF 自定义控件库 > [输入名称] > 保存时,立即出现错误:
The name "CustomControl1" does not exist in the namespace "clr-namespace:ProjectName"
我没有编辑任何代码,但立即出现错误。作为参考,错误在 Generic.xaml 中。
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ProjectName">
<Style TargetType="{x:Type local:CustomControl1}"> //<--Fails here
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}"> // Fails here as well
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
我正在使用 Visual Studio 12 和 .NET 4。有什么想法吗?
【问题讨论】:
-
你的
CustomControl1类的fully qualified名称是什么? -
我没有改变它。我创建了一个新项目(没有编辑任何内容),尝试构建,但由于该错误而无法构建。
标签: wpf visual-studio intellisense visual-studio-2012 xaml-designer