私の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() というコンストラクターがあります。この関数内でビューモデル内の変数を初期化しますが、イベントを押すたびに関数がリロードされるという問題があります。次に、ビューモデル内でビューのポストバック イベントをキャッチできるかどうかを確認したいと考えました。