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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With