C# &引用;类型引用找不到公共类型…”;WPF自定义控件中出现错误
我正在尝试我的第一个WPF自定义控件。我几乎什么都没做,它也不会编译。我在generic.xaml中得到一个错误,它说,“类型引用找不到名为'Filmstrip'的公共类型。第7行位置50(第7行是样式开始标记) Generic.xaml:C# &引用;类型引用找不到公共类型…”;WPF自定义控件中出现错误,c#,wpf,xaml,custom-controls,C#,Wpf,Xaml,Custom Controls,我正在尝试我的第一个WPF自定义控件。我几乎什么都没做,它也不会编译。我在generic.xaml中得到一个错误,它说,“类型引用找不到名为'Filmstrip'的公共类型。第7行位置50(第7行是样式开始标记) Generic.xaml: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsof
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespaces:Unicorn.Controls">
<Style TargetType="{x:Type local:Filmstrip}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Filmstrip}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
我缺少什么?
clr命名空间:Unicorn.Controls
应该是clr命名空间:Unicorn.Controls
。单数,而不是复数。您的xaml中似乎有语法错误。以下行:
xmlns:local="clr-namespaces:Unicorn.Controls"
应该是
xmlns:local="clr-namespace:Unicorn.Controls"
另外,除非这是您正在使用的程序集,否则不要忘记使用assembly参数引用其他程序集。在
xmlns:local
声明中是否缺少程序集规范?xaml与自定义控件类位于同一程序集中。您是否尝试过使用非静态公共构造函数?我说得对吗假设这会阻止编译,而不仅仅是一个错误的警告?@Hasanain:这应该会影响到这一点。在我的情况下,问题是一个不必要的“;装配=
xmlns:local="clr-namespace:Unicorn.Controls"