开发人员技术 | Visual Studio | 扩展
可增强和自定义 Visual Studio 集成开发环境的附加组件
扩展 Visual Studio 2022 的 XAML 设计器属性窗口(Property Grid),让某个类型的某个属性(比如 Human.Person)使用你自己的自定义编辑器,而不是默认的字符串/对象/集合编辑方式。是否支持这样做。有没有例子可以提供学习。
我尝试过 添加UITypeEditor ,无论是在源程序,还是在VSix 中,都不起作用。
public class Human
{
[Editor(typeof(PersonEditor), typeof(UITypeEditor))]
public Person Person { get; set; }
}
我也尝试下面的这种方式,也不成功。期待您的回复
public class Metadata : IRegisterMetadata
{
public void Register()
{
AttributeTableBuilder builder = new AttributeTableBuilder();
builder.AddCustomAttributes(
typeof(Human),
"Person",
new EditorAttribute(typeof(PersonEditor), typeof(UITypeEditor))
);
MetadataStore.AddAttributeTable(builder.CreateTable());
}
}