C#中在方括号内写的那种是什么?
[TemplatePartAttribute(Name = "PART_GlowRect", Type = typeof(FrameworkElement))][TemplatePartAttribute(Name = "PART_Track", Type = typeof(FrameworkElement))][TemplatePartAttribute(Name = "PART_Indicator", Type = typeof(FrameworkElement))]
]public class ProgressBar : RangeBase
比如这种在方括号里写的是什么?还有Nunit也会用到方括号,还有声明API也要用到方括号,这样写是什么意思啊?这个在C#里叫什么? --------------------编程问答-------------------- Attribute 特性 --------------------编程问答-------------------- 内部定义的元素被指定了TemplatePartAtrribute呢,可以在WPF Control库中查到,比如ProgressBar:
定义如下:
[TemplatePartAttribute(Name = "PART_Track", Type = typeof(FrameworkElement))]
[TemplatePartAttribute(Name = "PART_Indicator", Type = typeof(FrameworkElement))]
public class ProgressBar : RangeBase
得到附加属性列表的类
Type type = typeof(FrameworkElement);
http://msdn.microsoft.com/zh-cn/library/system.windows.frameworkelement.aspx --------------------编程问答-------------------- WPF自带的templdate中有很多以PART_开头的元素,这些元素都是用TemplatePartAttribute标记过,表示如果用户想自定义模版,必须提供同名及同类型的元素 --------------------编程问答-------------------- --------------------编程问答-------------------- /upload/20131225/6.gif --------------------编程问答-------------------- 是自定义属性,楼主可以参考下:
http://www.cnblogs.com/tuyile006/archive/2008/10/05/1304041.html --------------------编程问答-------------------- 特性。。。 --------------------编程问答-------------------- 推荐 --------------------编程问答-------------------- <a href="http://msdn.microsoft.com/zh-cn/library/system.attribute.aspx" title="Attribute 特性" target="_blank" >Attribute 特性</a> --------------------编程问答-------------------- <a href="http://msdn.microsoft.com/zh-cn/library/system.attribute.aspx" title="Attribute 特性" target="_blank" >Attribute 特性</a> --------------------编程问答-------------------- attribute. --------------------编程问答-------------------- attribute 属性,或特性 --------------------编程问答--------------------
强烈推荐
补充:.NET技术 , C#