Its perhaps easier to think that "references" never actually get "released". They simply fall in to disuse and can no longer be found by following any chain of reference from the global space or any thread stack. They are then considered garbage and at some point the collector will come and collect the memory they occupy. If they have finalisers it will not collect the memory immediately but place the object on a queue that will call the finaliser first.
A FrameworkElement
should not, for all sorts of reasons, call Dispose
on any reference held in its value dictionary when it is being unloaded. Primarly because it can't know that its responsible for doing that.
Imagine a scenario in which code elsewhere created a disposable object and also attached it to a framework element. What would happen if that code later attempted to use the object only to find that the framework element had taken it upon itself to dispose it?
It is the responsibility of the code that creates a disposable object to ensure that its disposed at the appropriate point.