views:

159

answers:

2

I am writing an app in Silverlight 3 using the Application Navigation template. So each page has a Loaded event, however I don't see a Closing event or an Unloaded event.

Does this concept even exist in SL3? For instance, how do I dispose of resources when this particular page closes and I navigate to another page in my app?

+2  A: 

Is this what you need: Page.OnNavigatedFrom Method ?

serialhobbyist
+1  A: 

There is no opposite to the Loaded event. If you hold resources that require disposing then you should implement IDisposable and ensure you dispose of them in your Dispose method. However that isn't a guarantee that the framework will call Dispose.

I'd be inclined to set up my disposable resources in the OnNavigatedTo method and then tear them down in the OnNavigatedFrom method.

AnthonyWJones