在我的 ViewModel 中,我有以下代码:
using System;
using DotVVM.Framework.ViewModel;
using DotVVM.Framework.Controls.Bootstrap;
using APP_MIS_FACTURAS.DTO.Contoles;
using System.Collections.Generic;
using APP.Models.View;
namespace APP.ViewModels
{
public class InicioViewModel : DotvvmViewModelBase
{
// Variables para la Vista
private InicioModel inicioModel = new InicioModel();
private bool constructor = true;
private SelectDTO[] inicializaLista;
// Mensaje 1
[Bind(Direction.ServerToClient)]
public string AlertText1 { get; set; }
[Bind(Direction.ServerToClient)]
public AlertType AlertType1 { get; set; }
public bool Dismissed1 { get; set; }
// Mensaje 2
[Bind(Direction.ServerToClient)]
public string AlertText2 { get; set; }
[Bind(Direction.ServerToClient)]
public AlertType AlertType2 { get; set; }
public bool Dismissed2 { get; set; }
// Mensaje 3
[Bind(Direction.ServerToClient)]
public string AlertText3 { get; set; }
[Bind(Direction.ServerToClient)]
public AlertType AlertType3 { get; set; }
public bool Dismissed3 { get; set; }
// Pagina Inicio
public string usuario { get; set; }
public string password { get; set; }
// Recuperar contrasena
public string correoElectronico { get; set; }
// Registro de usuario
public string nombre { get; set; }
public string apellidoPaterno { get; set; }
public string apellidoMaterno { get; set; }
public bool aceptoTerminos { get; set; }
public SelectDTO[] genero { get; set; }
public int selectGenero { get; set; } = 0;
public InicioViewModel()
{
if (constructor)
{
AutenticarAplicacion();
Limpiar();
inicializaLista = CargaCatalogoGenero();
constructor = false;
}
}
public void Limpiar()
{
//Clean Form Data
}
public void Autenticar()
{
// Operations to validate user
}
public void RegistroUsuario()
{
//Operations to create a user
}
private void AutenticarAplicacion()
{
//Operations to validate the status of the application
}
private SelectDTO[] CargaCatalogoGenero()
{
//Loading catalogs (Call database)
}
}
}
我有一个名为 InicioViewModel () 的构造函数。在这个函数中,我初始化了视图模型中的变量,但我遇到的问题是每次按下任何事件都会重新加载函数。然后想检查是否有可能在视图模型内部我可以捕获视图的回发事件。