1

I'm on writing a simple application, it has a menu and when user choices each MenuItem, i want to change my window's content to display the selected content.

i have two option to that.

  1. i can add a <Frame></Frame> to my window and write some pages.
  2. i can write some UserControls and put them in a ContentControl

as user fires MenuItem click event.

so I'm confused to select the right choice for this purpose.

RezaNoei
  • 1,266
  • 1
  • 8
  • 24
  • 1
    Frame/Page have some gotchas, e.g. https://stackoverflow.com/questions/3621424/page-datacontext-not-inherited-from-parent-frame. If you don't need isolation specifically, then stick to ContentControl – ASh May 18 '18 at 09:32

1 Answers1

1

Navigation can be succefully implemented by using Frame/Pages or ContentControl/Views. It is a matter of choice.

However, Frame/Page have some gotchas, e.g. page.DataContext not inherited from parent Frame?

If you don't need isolation specifically, then stick to ContentControl. Navigation in framework is built with regions which are located in different type of controls (e.g. ContentControl, TabControl), not Frame (see docs)


one more approach for simple navigation is ViewModel based.

Examples:

WPF MVVM navigate views

Navigation with MVVM by Rachel Lim (external)

ASh
  • 34,632
  • 9
  • 60
  • 82