title: How to detect when a templated UserControl is removed from UI (not just hidden in UI)
body: <p>I have an <code>ItemsControl</code> with its <code>ItemsSource</code> bound to an <code>ObservableCollection&lt;T&gt;</code>, using my own <code>UserControl</code> as the <code>ItemTemplate</code>:</p>
  
  <pre><code>&lt;ItemsControl ItemsSource="{Binding Path=MyObservableColletion, Mode=OneWay}"&gt;
  
    &lt;ItemsControl.ItemTemplate&gt;
      &lt;DataTemplate&gt;
        &lt;MyControls:MyUserControl /&gt;
      &lt;/DataTemplate&gt;
    &lt;/ItemsControl.ItemTemplate&gt;
  
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>I've got it hooked up so that the UI is updated as items are added/removed to/from the collection.</p>
  
  <p><strong>When an item is removed from the collection, I want to detect this in the code-behind of the representative templated <code>MyUserControl</code>. How can I do this?</strong></p>
  
  <p>I did notice that the <code>Unloaded</code> event fires in this case, but it's not adequate for my purpose because <code>Unloaded</code> also fires when the UI containing my <code>ItemsControl</code> is simply hidden/collapsed (e.g. when it's in a <code>TabControl</code> and the tab is switched away).</p>
  
  <p>Is there another event for this purpose, or a way of detecting in the body of an <code>Unloaded</code> handler that my control is definitely removed and not just hidden?</p>