I am developing a custom user control. The user control has a property that maps to an enumeration and should not have any default value, i.e. the consumer of the control MUST set it.
The property:
<Description("This is the property description"),
Category("SomeCategory"), Bindable(True)>
Public Property SomeProperty As Enumerations.SomeEnumeration?
The enumeration:
Namespace Enumerations
Public Enum SomeEnumeration
Zero = 0
One
Two
End Enum
End Namespace
The check:
If SomeProperty Is Nothing Then
Throw New ApplicationException("You must set SomeProperty.")
End If
The problem:
All of the logic works. My problem is that none of the enumeration values show up in intellisense when you try to set SomeProperty from markup. A colleague of mine found this related support request, so it appears to be a known issue.
My question is, what is the best way to support all of the behaviors I need on this control, as well as keep intellisense on this property?
I could recreate this issue – making an enumeration nullable makes the intellisense stop working. I guess this is because nullable types are objects.
Suggest keeping the enumeration as NOT nullable. Have a default value of
NotSetorNone. If the enumeration is not set, you could throw an exception in your getter or initialization code.Property
Enumeration
Check