Search code examples
silverlightmemory-leaksweak-events

What's a good implementation of weak events for silverlight?


I'm after a good implementation of the weak event patterns for Silverlight to avoid memory leaks. There seem to be a few implementations out there but the code is not trivial and it's hard to know which one is correct. I can't find any official recommendation from Microsoft.

I'm after a simple syntax if possible.

Cheers.


Solution

  • Install a copy of the Silverlight Toolkit which comes with source code zipped up. In there you will find the pattern of weak events that you might consider the "Microsoft" recommendation. (You can also fetch the latest source from codeplex).

    The implementation you are after is WeakEventListener found in the Common folder of he main Controls.Toolkit project.