290

What is the difference between a Page and a Window in WPF when you are adding a new file in the Solution Explorer?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
HelloWorld1
  • 13,688
  • 28
  • 82
  • 145

4 Answers4

293

Pages are intended for use in Navigation applications (usually with Back and Forward buttons, e.g. Internet Explorer). Pages must be hosted in a NavigationWindow or a Frame

Windows are just normal WPF application Windows, but can host Pages via a Frame container

Jimmy
  • 6,001
  • 1
  • 22
  • 21
  • 22
    If a new Page is opened the previous page is destroyed and it's code stop's executing , But when a new window is opened both Window's code run parallel unless `ShowDialog();` is used – user0331 Aug 07 '14 at 10:24
50

A Window is always shown independently, A Page is intended to be shown inside a Frame or inside a NavigationWindow.

H H
  • 263,252
  • 30
  • 330
  • 514
23

Page Control can be contained in Window Control but vice versa is not possible

You can use Page control within the Window control using NavigationWindow and Frame controls. Window is the root control that must be used to hold/host other controls (e.g. Button) as container. Page is a control which can be hosted in other container controls like NavigationWindow or Frame. Page control has its own goal to serve like other controls (e.g. Button). Page is to create browser like applications. So if you host Page in NavigationWindow, you will get the navigation implementation built-in. Pages are intended for use in Navigation applications (usually with Back and Forward buttons, e.g. Internet Explorer).

WPF provides support for browser style navigation inside standalone application using Page class. User can create multiple pages, navigate between those pages along with data.There are multiple ways available to Navigate through one page to another page.

Sanket Gawade
  • 341
  • 2
  • 8
2

The main difference is Window is complete as a whole and cannot be contained in a page but vice-versa is possible. Pages are used to provide different tabs to a user in the same window.

see the attached image

enter image description here