gpt4 book ai didi

c# - WPF自定义控件中的"The type reference cannot find a public type..."错误

转载 作者:行者123 更新时间:2023-12-02 14:45:55 25 4
gpt4 key购买 nike

我正在尝试我的第一个 WPF 自定义控件。我几乎没有做过任何事情,它不会编译。我在 generic.xaml 中收到错误消息:“类型引用找不到名为“Filmstrip”的公共(public)类型。第 7 行位置 50(第 7 行是样式开始标记)

Generic.xaml:

<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>

Filmstrip.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Unicorn.Controls
{
public class Filmstrip : Control
{
static Filmstrip()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Filmstrip), new FrameworkPropertyMetadata(typeof(Filmstrip)));
}
}
}

我错过了什么?

最佳答案

clr-namespaces:Unicorn.Controls 应为 clr-namespace:Unicorn.Controls。单数,非复数。

关于c# - WPF自定义控件中的"The type reference cannot find a public type..."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7263570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com