Reputation: 11057
PropertyDescriptor
is an abstract class from which custom property descriptors can inherit. The class has an IsBrowsable
property, which, according to MSDN:
Gets a value indicating whether the member is browsable, as specified in the BrowsableAttribute. (Inherited from MemberDescriptor.)
My question is, how is this property related to the BrowsableAttribute
in PropertyDescriptor.Attributes
, for the associated property (defined e.g. by adding the [Browsable(false)]
decorator to the property?
My confusion arises from the fact that I managed to replace the BrowsableAttribute
with PropertyDescriptor.Attributes
a new one, which was inconsistent with IsBrowsable
.
Update
Following Marc's answer, must I keep the BrowsableAttribute
in sync with IsBrowsable
? Are you aware of any controls which may look at one but not the other?
Upvotes: 2
Views: 738
Reputation: 1064114
The default PropertyDescriptor implementation uses reflection and looks at the BrowsableAttribute. However, if you are providing your own PropertyDescriptor implementation then you are in charge - there are very few things that need to be followed. If your custom implementation uses an unrelated way to determine what is / is not browsable : that is up to your implementation.
Upvotes: 3