in xaml, is it bad practice to use a frame, inside a window to display pages?

Toadums picture Toadums · Jul 6, 2011 · Viewed 21.2k times · Source

I was just wondering what the common practice is, to have pages (I dont mean pages as in XAML pages, I just mean...different screens) which can be navigated between?

Right now I am using just a bunch of pages, and using the NavigationService class in C# to navigate between my pages. But I just discovered Frames.

Is it better to have a frame inside a window:

<window>
    <frame source="page.xaml" />
</window>

or just do it with all the different pages and the NavigationServices? Or should I be using a window inside the frame?

What do you do??

Thanks!

Answer

sellmeadog picture sellmeadog · Jul 7, 2011

Frames are commonly used when building a navigation based application in WPF. However, there's a lot to learn about the WPF navigation system and a few things you need to know about the page life cycle, etc. to avoid memory leaks and unexpected behavior.

This is a great overview by Paul Stovell: http://www.paulstovell.com/wpf-navigation