Once I asked how to display multiple views in one window in a windows-forms-application (link). Now I'd like to know how to do the same in an WPF-application.
You could have in your MainWindow.xaml, just one Stackpanel. Nothing else. You define all your views in other xaml files. Just that the parent element is not a Window. You need to have it as a Grid/StackPanel. When you want to load a new view, you just set the appropriate view's root element(or the view itself) as the Children of the StackPanel in MainWindow.xaml
Your best option is to use an MVVM framework such as Caliburn.Micro, which makes view composition very easy. In this case, you would have your shell screen for example, which would be a conductor, and each of your sub screens would just be other view models, which your shell would have references to, and each would become the active item when they needed to be displayed.
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