I have a UserControl that implements an interface class IPropertyListItemType. I would like that the interface class requires it to override the Enabled property of the control. Within my interface class I have:
bool Enabled { get; set; }
Within my derived class (i.e. the UserControl), I currently have:
bool IPropertyListItemType.Enabled
{
get { return _enabled; }
set
{
_enabled = value;
lblStatus.Text = _enabled ? "Enabled" : "Disabled";
//lblStatus.BackColor = _enabled ? SystemColors.Window : SystemColors.Control;
}
}
However, when the Enabled property on the user control is set, the code within the Enabled property of the UserControl is not executed, just that of the UserControl. I cannot place override in the interface class (The modifier 'override' is not valid for this item), or on the derived class (again, The modifier 'override' is not valid for this item).
How can I require that an override is implemented on the derived class?
Keep the interface as you have it:
In the header of the implementation, shadow the base class method using the
new
keyword so that your one gets called instead of the default one.