title: SL custom control: When unregister event to prevent memory leak?
body: <p>I'm creating some custom wp7 silverlight custom controls which register some events on template children in OnApplyTemplate().</p>
  
  <p>I think I must unregister these to prevent a memory leak. But when? I'll tried the unloaded event - this works but I have a problem with this.
  The scenario:
  On Page1 I have my custom control. Then navigating away from Page1 to Page2 the Unloaded event of my custom control is called. So far so good. But then I navigate back the events of my custom control aren't registered again so nothing happens then using that control.</p>
  
  <p>Then should I register and unregister events correctly that everything works as expected and I can't create a memory leak?</p>
  
  <p>Thanks for your help!</p>
  
  <p>Edit:</p>
  
  <p>Here an example of my OnApplyTemplate() method:</p>
  
  <pre><code>public override void OnApplyTemplate()
  {
      base.OnApplyTemplate();
  
      _itemsContainer = GetTemplateChild("PART_Items") as ItemsControl;
      if (_itemsContainer != null)
      {
          // When to detach this event for correctly object lifetime?
          _itemsContainer.Tap += ItemsContainer_Tap;
      }
  }
  </code></pre>