C# 如何对控件的属性进行分类,使其显示在Blend和Visual studio designer中的适当部分?
在以前的XAML技术中,您可以向依赖项属性添加C# 如何对控件的属性进行分类,使其显示在Blend和Visual studio designer中的适当部分?,c#,visual-studio,xaml,windows-runtime,blend,C#,Visual Studio,Xaml,Windows Runtime,Blend,在以前的XAML技术中,您可以向依赖项属性添加CategoryAttribute,它将出现在Blend和Visual Studio的属性窗口中 例如,我想向自定义控件添加一个新的Brush属性,并将其显示在“外观”类别下 [Category("Appearance")] public Brush MyAwesomeBrush { get {...} set {...} } 有没有办法为Windows应用商店应用程序(Win8/Win10/Phone/etc)执行此操作 根据帖子,它在Windo
CategoryAttribute
,它将出现在Blend和Visual Studio的属性窗口中
例如,我想向自定义控件添加一个新的Brush
属性,并将其显示在“外观”类别下
[Category("Appearance")]
public Brush MyAwesomeBrush { get {...} set {...} }
有没有办法为Windows应用商店应用程序(Win8/Win10/Phone/etc)执行此操作 根据帖子,它在Windows应用商店应用程序等中不受支持。如果你真的愿意,你可以这样做 将以下类添加到项目中(保留名称空间,所有内容都以这种方式进行): 这样使用它:
namespace System.ComponentModel
{
[AttributeUsage(AttributeTargets.All)]
public class CategoryAttribute : Attribute
{
public CategoryAttribute(string category)
{
Category = category;
}
public string Category { get; private set; }
public override bool Equals(object obj)
{
if (obj == this)
return true;
var other = obj as CategoryAttribute;
return other != null && other.Category == Category;
}
public override int GetHashCode()
{
return Category.GetHashCode();
}
}
}
还有tada.wav,它是有效的:)
好极了!真管用!我们还可以对哪些属性这样做呢?我想如果Blend可以被欺骗使用这个属性,那么大多数属性可能也会起作用<代码>描述属性也可以使用。代码同上。我再试试。