I have a generic EventArgs
class defined as:
public class GenericEventArgs<T> : EventArgs
{
public GenericEventArgs(T value)
{
Data = value;
}
public T Data { get; private set; }
}
If I add an event
of type EventHandler<T>
to my UserControl
, it will only appear in the Designer if I subclass my generic EventArgs
type.
// this event will not appear in Designer
public event EventHandler<GenericEventArgs<String>> Event1;
// this event appears in Designer as expected
public event EventHandler<StringEventArgs> Event2;
where StringEventArgs
is defined as:
public class StringEventArgs : GenericEventArgs<String>
{
public StringEventArgs(String value)
: base(value)
{
}
}
I have tried adding the [Browsable(true)]
attribute to the event, and marking the EventArgs<T>
class as Serializable
without success.
What could be causing this, and is there a workaround (other than subclassing) available?
I am using VS2010 and .NET 4.0.