I have a WPF UserControl
that is added as Content
in a TabItem
. The TabItem
is added to the Items
collection of TabControl
. The Header
of the TabItem
contains one Label
and one Button
. The button click removes the TabItem from the Items collection of TabControl. So the reference of UserControl is not there anymore. I have some clean up code to be run for the UserControl when the TabItem is removed.
I was looking for Dispose
method in the UserControl, but there is no such method available for overriding.
Also, I tried to use Dispatcher.ShutdownStarted
Event, but that also doesn't work.