diff --git a/src/Tizen.NUI/src/internal/Common/WeakEvent.cs b/src/Tizen.NUI/src/internal/Common/WeakEvent.cs index a2745cf5500..e886b935e7c 100755 --- a/src/Tizen.NUI/src/internal/Common/WeakEvent.cs +++ b/src/Tizen.NUI/src/internal/Common/WeakEvent.cs @@ -130,4 +130,39 @@ private void OnEventInvoked(object sender, EventArgsT args) Invoke(sender, args as EventArgs); } } + + /// + /// The non-generic version of . + /// + internal abstract class WeakEventProxy : WeakEvent + { + protected abstract void ConnectToEvent(EventHandler handler); + + protected abstract void DisconnectToEvent(EventHandler handler); + + public override void Add(EventHandler handler) + { + if (Count == 0) + { + ConnectToEvent(OnEventInvoked); + } + + base.Add(handler); + } + + public override void Remove(EventHandler handler) + { + base.Remove(handler); + + if (Count == 0) + { + DisconnectToEvent(OnEventInvoked); + } + } + + private void OnEventInvoked(object sender, EventArgs args) + { + Invoke(sender, args); + } + } }