【发布时间】:2020-01-02 19:06:08
【问题描述】:
所以我知道这个问题已经被问过很多次了,我已经阅读了大约 10 篇关于这个问题的帖子。我已重新启动 Visual Studios,但仍然出现错误。
The Member IcoIcon is not recognized or accessible
这是我的代码
public partial class Icomoon : UserControl
{
public static readonly DependencyProperty IcoIconProperty =
DependencyProperty.Register("IcoIcon", typeof(string), typeof(Icomoon), new PropertyMetadata(null));
public object IcoIcon
{
get => (string)GetValue(IcoIconProperty);
set => SetValue(IcoIconProperty, IcoMoonVariables.Invoke((string)value));
}
public Icomoon()
{
InitializeComponent();
}
}
因此,据我所知,我已正确注册它,并且当我输入它时它会显示在 Intellisense 中。但它仍然给我错误。
<UserControl:Icomoon IcoIcon="LineGraph" />
我是否忽略了成员的班级名称?我已经研究了一段时间,所以任何方向感都会有所帮助。建议赞赏
【问题讨论】:
-
在 XAML 中声明元素时,
:之前的字符串应该是声明类的NameSpace。你有UserControl:Icomoon,UserControl是你给命名空间的标签吗? -
是的,它是标签
-
UserControl:Icomoon=>local:Icomoon -
我还看到您的 DependencyProperty 注册为
string,但普通属性是object。也许这与它有关? -
所以你重建并且错误仍然存在,但是你运行它并且它消失了?去搞清楚。好吧,至少它现在已经消失了。
标签: c# wpf dependency-properties