Switching between WPF XAML views using MVVM DataTriggers
Related post: https://www.technical-recipes.com/2016/switching-between-wpf-xaml-views-using-mvvm-datatemplate/ This post addresses the problem of being able to switch between different views based on the property of a ViewModel class. To get started in Visual Studio, create a new WPF Application: So that when we build and run the application we have a blank window like this: To demonstrate how WPF windows can be made to switch between different views, create two new XAML views, View1.xaml and View2.xaml, each consisting of a simple TextBlock containing different texts to demonstrate that the views are different. In your Visual Studio project, right-click your project folder and select Add > New Item. Select User Control (WPF) and name your file as View1.xaml: In the xaml portion of the file, insert the code to display the Text in the view as follows: [code language="xml"] <UserControl x:Class="XamlSwitching.View1" xmlns=...