C# 自定义控件属性的默认样式设置器处的XamlParseException
请原谅这个迟钝的标题,不知道如何最好地表达我的问题 我在projectfoo中编写了一个自定义控件“CustomControl”。它有一个依赖属性“Title”,它是一个字符串:C# 自定义控件属性的默认样式设置器处的XamlParseException,c#,xaml,custom-controls,winrt-xaml,xamlparseexception,C#,Xaml,Custom Controls,Winrt Xaml,Xamlparseexception,请原谅这个迟钝的标题,不知道如何最好地表达我的问题 我在projectfoo中编写了一个自定义控件“CustomControl”。它有一个依赖属性“Title”,它是一个字符串: public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( "Title", typeof(string), typeof(C
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register(
"Title",
typeof(string),
typeof(CustomControl),
PropertyMetadata.Create("Default Title")
);
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
在我的Generic.xaml文件中,我试图使用Setter节点设置“Title”的值:
<Style TargetType="local:CustomControl">
<!-- Setter for Template property -->
<Setter Property="Title" Value="Any String" />
</Style>
应用程序在尝试呈现控件时立即阻塞,表示无法在我的控件中找到“Title”属性:
Foo.exe中发生类型为“Windows.UI.Xaml.Markup.XamlParseException”的异常,但未在用户代码中处理
WinRT信息:在类型“Foo.Controls.CustomControl”中找不到属性“Title”。[行:X位置:Y]
附加信息:未指定的错误
我做错什么了吗?这是不允许的吗?
当我打开调试器时,我可以看到对象上的Title属性,所以我很困惑。我觉得很傻,最好删除这个问题,因为经过几个小时的拉扯,我在发布问题10秒后解决了它
问题出在我的财产上。登记电话。我的所有者类型(第三个参数)引用了一个名称非常相似的类,而不是实际拥有的类。哎呀(不要删除。我也这么做了。)