tags:

views:

361

answers:

1

Hi,

I've created a WPF application with a frame inside. I can attach some other pages to this frame like

frame1.Source = new Uri("Page1.xaml", UriKind.RelativeOrAbsolute);

The question is after loading this page (Page1.xaml) an Load another page in the same frame (Page2.xaml) is the Page1.xaml disposed automaticly or is it still running in background? I could not find a dispose method for a frame source page. Can anyone explain this please.

+2  A: 

Frame is designed to provide the ability for navigating content; the preferred way to package content for navigation is a Page as you are doing. Specifically, the Frame can be navigated with the Navigate methods and will maintain the lifetime of navigation history, where "history" is the keyword here.

Within the history of the navigation, the Frame will not maintain an instance of each Page navigated to avoid excessive memory consumption. Consequently, the state is not remembered when using the Navigation controls and a new instance is created each time the page is navigated to.

In other words, when you navigate away from a page in a frame, the object is disposed.

MSDN has a good read on using Frames.

Metro Smurf
Thank you very much that was a clear answer :)
Shift