[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#里叫什么?

解决方案 »

  1.   

    Attribute 特性
      

  2.   

    内部定义的元素被指定了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
      

  3.   

    WPF自带的templdate中有很多以PART_开头的元素,这些元素都是用TemplatePartAttribute标记过,表示如果用户想自定义模版,必须提供同名及同类型的元素
      

  4.   

    http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/6.gif
      

  5.   

    是自定义属性,楼主可以参考下:
    http://www.cnblogs.com/tuyile006/archive/2008/10/05/1304041.html
      

  6.   

    <a href="http://msdn.microsoft.com/zh-cn/library/system.attribute.aspx" title="Attribute 特性" target="_blank" >Attribute 特性</a>
      

  7.   

    <a href="http://msdn.microsoft.com/zh-cn/library/system.attribute.aspx" title="Attribute 特性" target="_blank" >Attribute 特性</a>