是将Model_1描述添加到所有类的编程实践,还是特定于UI元素
例如,我在MS文档上发现了这段代码。
型号1
[Description("Represents a custom button control that responds to a Click event. Displays an image using a custom Source property if the Source property is bound to an Image in the template.")]
public class ImageButton : Button
与有什么不同?
型号2
/// <summary>
///Represents a custom button control that responds to a Click event. Displays an image using a custom Source property if the Source property is bound to an Image in the template.
///</summary>
public class ImageButton : Button
在哪里可以同时使用这两种方法或具体使用Model_1描述
由于没有其他答案,这就是我的研究结果!
模型1-描述属性
模型2-XML注释
一般来说,使用XML注释来记录C#代码是一种很好的做法,因为它们提供了可用于生成API文档的更详细的信息。但是,Description属性对于提供WPF应用程序中UI元素的目的和行为的简明摘要非常有用。