【发布时间】:2019-05-20 02:30:49
【问题描述】:
当“排列方式:类别”处于活动状态时,某些本机 WPF 控件具有属性类别“文本”,它们在属性检查器中列出在该类别下。但是,当我尝试使用
为我的 WPF 自定义控件的属性设置此类别时[Category("Text")]
它不起作用。该属性未出现在任何类别中。 (使用 VS 2015 测试。)
这与System.ComponentModel.CategoryAttribute 不包含文本类别的事实一致。
但是如何才能将属性与 Text 类别相关联呢?
编辑:为了澄清,这里是原代码中属性实现的相关部分:
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
...
public static readonly DependencyProperty IsReadOnlyProperty;
...
[Browsable(true)]
[Category("Text")]
[Description("Gets or sets a value that indicates whether the text editing control is read-only to a user interacting with the control.")]
public bool IsReadOnly
{
get { return (bool)GetValue(IsReadOnlyProperty); }
set { SetValue(IsReadOnlyProperty, value); }
}
【问题讨论】: