C# UWP&x27;风格';Visual Studio未找到属性';编辑其他模板';
使用Visual Studio中的文档大纲窗格,可以右键单击列表框实例,显示的菜单中有一个选项,可用于为列表框的公开样式属性生成样式。您可以在红色矩形内看到以下内容:- 我创建了自己的控件并公开了一个样式类型属性。我希望Visual Studio发现我的属性并提供相同的功能。但即使我用StyleTypedProperty属性标记类,它也不起作用 下面是一个类的代码示例:-C# UWP&x27;风格';Visual Studio未找到属性';编辑其他模板';,c#,visual-studio,uwp,design-time,C#,Visual Studio,Uwp,Design Time,使用Visual Studio中的文档大纲窗格,可以右键单击列表框实例,显示的菜单中有一个选项,可用于为列表框的公开样式属性生成样式。您可以在红色矩形内看到以下内容:- 我创建了自己的控件并公开了一个样式类型属性。我希望Visual Studio发现我的属性并提供相同的功能。但即使我用StyleTypedProperty属性标记类,它也不起作用 下面是一个类的代码示例:- [StyleTypedPropertyAttribute(Property = "Example", StyleTarge
[StyleTypedPropertyAttribute(Property = "Example", StyleTargetType = typeof(Button))]
public sealed class ExampleControl : Control
{
public static readonly DependencyProperty ExampleStyleProperty =
DependencyProperty.Register(
"ExampleStyle",
typeof(Style),
typeof(ExampleControl),
new PropertyMetadata(null, OnExampleStyleChanged));
public ExampleControl()
{
this.DefaultStyleKey = typeof(ExampleControl);
}
public Style ExampleStyle
{
get { return GetValue(ExampleStyleProperty) as Style; }
set { SetValue(ExampleStyleProperty, value); }
}
private static void OnExampleStyleChanged(DependencyObject sender,
DependencyPropertyChangedEventArgs args)
{
}
}
我认为该属性只是一个定义,表示style属性是此类控件类型的目标,Visual Studio或Blend无法识别该属性,但对使用您的控件的人来说是有意义的。@WPInfo不,它应该可以工作。它在VS2015中工作,但目前在VS2017中中断。顺便说一句,
Property=“Example”
是错误的,它应该是Property=“ExampleStyle”
,或者Property=nameof(ExampleStyle)
。但它仍然不起作用。你最好报告这个问题,通过Visual Studio报告。我认为该属性只是一个定义,表示style属性是此类控件类型的目标,Visual Studio或Blend无法识别它,但对使用你的控件的人有意义。@WPInfo否,这应该是有效的。它在VS2015中工作,但目前在VS2017中中断。顺便说一句,Property=“Example”
是错误的,它应该是Property=“ExampleStyle”
,或者Property=nameof(ExampleStyle)
。但它仍然不起作用。你最好在网上报告这个问题,通过VisualStudio报告就可以了。