Page - GetcuReone/MvvmFrame.Wpf GitHub Wiki
This is one of the main parts that contains a set of methods for working with a view. With its help, the library can bind view and view-model
Let's find out by example.
- Create an empty WPF application. I will call him Example_MvvmFrame.Wpf
- Download the NuGet 'MvvmFrame.Wpf' to the project.
- For ease of understanding, create a subfolder 'Pages'
- In this folder we create the page 'HomePage' and open its code behind. Before you should be the following picture
namespace Example_MvvmFrame.Wpf.Pages
{
/// <summary>
/// Interaction logic for HomePage.xaml
/// </summary>
public partial class HomePage : Page
{
public HomePage()
{
InitializeComponent();
}
}
}
- Remove the default constructor. Inherit the class 'HomePage' from the interface 'MvvmFrame.Interfaces.IPage' and implement the interface method like this:
namespace Example_MvvmFrame.Wpf.Pages
{
/// <summary>
/// Interaction logic for HomePage.xaml
/// </summary>
public partial class HomePage : Page, IPage
{
public void InitializePageComponent<TViewModel>(TViewModel viewModel) where TViewModel : IViewModel
{
DataContext = viewModel;
InitializeComponent();
}
}
}
That's all. Your page is ready to go :) Further work on view-model
This example is useful for further study of the library.