6

假设我有一个这样定义的附加属性:

    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) 和访问器 ( GetMyPropertyand SetMyProperty) 编写文档,但我不知道将MyClass.MyProperty 附加属性的文档放在哪里,因为它不是实际的代码元素。

MSDN 库包含此类文档(参见示例Grid.Row),因此它必须是可能的......

我应该将附加属性的 XML 文档注释放在哪里?

4

2 回答 2

3

一篇关于 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));
于 2009-08-03T20:37:28.380 回答
1

尽管答案有点晚了,但我已经找到了在 Visual Studio 运行时出现文档的解决方案。

如果您使用 ReSharper 并按下CTRLQ,则添加在SetXXX-method 上方的 XML-Documentation 用于显示Quick-Documentation.

于 2016-02-23T08:44:12.627 回答