如何为附加属性添加XML文档注释?您应该将XML文档注释放在附加属性的定义处。

6
假设我有一个如下所示的附加属性定义:
```xml ```

假设我有一个如上所示的附加属性定义:

    public static string GetMyProperty(DependencyObject obj)
    {
        return (string)obj.GetValue(MyPropertyProperty);
    }

    public static void SetMyProperty(DependencyObject obj, string value)
    {
        obj.SetValue(MyPropertyProperty, value);
    }

    // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty MyPropertyProperty =
        DependencyProperty.RegisterAttached("MyProperty", typeof(string), typeof(MyClass), new UIPropertyMetadata(0));

我可以为属性标识符 (MyPropertyProperty) 和访问器 (GetMyPropertySetMyProperty) 编写文档,但我不知道应该在哪里放置关于 MyClass.MyProperty 附加属性的文档 ,因为它不是一个实际的代码元素。 MSDN库包含这样的文档(请参见例如Grid.Row),所以一定有可能... 请问我应该在哪里为附加属性放置XML文档注释?
2个回答

3

There's an article about that for Sandcastle:

/// <summary>
/// This defines the <see cref="P:TestDoc.TestClass.IsBroughtIntoViewWhenSelected"/>
/// attached property.
/// </summary>
///
/// <AttachedPropertyComments>
/// <summary>This attached property indicates whether or not a tree view item is
/// brought into view when selected.
/// </summary>
/// <value>The default value is false</value>
/// </AttachedPropertyComments>
public static readonly DependencyProperty IsBroughtIntoViewWhenSelectedProperty =
    DependencyProperty.RegisterAttached("IsBroughtIntoViewWhenSelected",
typeof(bool), typeof(TestClass),
new UIPropertyMetadata(false, OnIsBroughtIntoViewWhenSelectedChanged));

1
仅包含损坏链接的链接答案。 - wondra

1
即使回答有点晚,我已经找到了一个解决方案,可以在 Visual Studio 运行时显示文档。
如果您使用 ReSharper 并按 CTRLQ,则会使用添加在 SetXXX 方法上方的 XML 文档来显示 Quick-Documentation

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接