How To: Create a ViewModel or Model from Classes
In this guide, we will look at how to create a new class element in Visual Studio and then create either a ViewModel or a Model for use in an Uno Platform application with MVUX.
For the following steps, let's assume the page that the element to be created belongs to is called SamplePage.xaml
Add a new item (for use as Model or ViewModel):
- Right-click on the Presentation folder in the Solution Explorer on the right
- Select Add
- Then click on New Item

Create a Class element:
- Select the
Classelement in the list and name it according to the following scheme:
Your application uses:
- Mvvm:
SampleViewModel.cs - Mvux:
SampleModel.cs
- Select the
Now click Add.

To create a Model suitable for Mvux:
- Insert
partialbefore the currentclass. - Replace
classwithrecord - With the snippet shortcut
ctoryou can also automatically insert a (secondary) constructor.

