Step: 5
Create a model, here Employee is our model name. In this model, we can add the Employee name, id, and designation.
Employee.cs
using System;
usingSystem.Collections.Generic;
usingSystem.Text;
namespaceEventToCommand
{
publicclassEmployee
{
publicintIdofEmployee{ get; set; }
publicstringNameofEmployee{ get; set; }
publicstringDesignationofEmployee{ get; set; }
}
}
After creating a model, create a one ViewModel, in this ViewModel we can use the CleanUp command and Refresh command from the CommandModel on your page. In this ViewModel, we can inherit the CommandModel class.
MainViewModel.cs
using System;
usingSystem.Collections.Generic;
usingSystem.Collections.ObjectModel;
usingSystem.Text;
namespaceEventToCommand
{
publicclassMainViewModel :CommandModel
{
publicMainViewModel()
{
}
privateObservableCollection _employee;
publicObservableCollection employees
{
get
{
return _employee;
}
set
{
Set(() => employees, ref _employee, value);
}
}
publicoverridevoidRefreshPage()
{
base.RefreshPage();
this.employees = newObservableCollection();
this.employees.Add(new Employee { IdofEmployee = 101, NameofEmployee = "John", DesignationofEmployee = "HR" });
this.employees.Add(new Employee { IdofEmployee = 102, NameofEmployee = "Jack", DesignationofEmployee = "Marketing" });
this.employees.Add(new Employee { IdofEmployee = 103, NameofEmployee = "Mickel", DesignationofEmployee = "Tester" });
this.employees.Add(new Employee { IdofEmployee = 104, NameofEmployee = "Smith", DesignationofEmployee = "BA" });
}
publicoverridevoidCleanUpPage()
{
this.employees = null;
base.CleanUpPage();
}
}
}