What do the views built on Josh Smith's MVVM look like?

Being new to both WPF and MVVM, I am exploring an article by Josh Smith on the MVVM pattern and accompanying sample code.

I see that the application starts in app.xaml.cs , creating the MainWindow object, app.xaml.cs it into the MainWindowViewModel object and then displaying the main window. So far so good.

However, I cannot find the code that instantiates the classes AllCustomersView or CustomerView . Using "find all links" on the constructors of these views does not lead to anything. What am I missing here?

+4
source share
1 answer

WPF DataTemplate does the magic. For example, when you set the Contentcontrol content with an instance of CustomerViewModel with the DataTemplate below in your resource dictionary (usually in app.xaml). You will then see that CustomerView user control appears in the user interface.

 <DataTemplate DataType="{x:Type vm:CustomerViewModel}"> <vw:CustomerView /> </DataTemplate> 
+6
source

Source: https://habr.com/ru/post/1303993/


All Articles