Another option is to delegate the event to the original class:
public class ClassA
{
private ClassB classB = new ClassB();
public event EventHandler SomeEvent
{
add
{
classB.SomeEvent += value;
}
remove
{
classB.SomeEvent -= value;
}
}
}
That means when the event is raised in ClassB
, all subscribers to ClassA.SomeEvent
will also be notified because they are - in fact - subscribed to ClassB.SomeEvent
. I'm not sure if that is going to be what you really want, but in any case, you can always use subscribe-and-raise method.
There's a catch here though: the sender
object will be an instance of ClassB
, not ClassA
, which means that you can't delegate the event in, for example, WPF with INotifyDataErrorInfo
validation, where the view model itself is expected to be raising the validation event. Then you just have to subscribe-and-raise.