MainWindowViewModel.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Avalonia.Controls;
  2. using kuzminIVProjectWorkOnDemo.Models;
  3. using ReactiveUI;
  4. namespace kuzminIVProjectWorkOnDemo.ViewModels
  5. {
  6. public class MainWindowViewModel : ViewModelBase
  7. {
  8. static KuzmintestprojContext db = new KuzmintestprojContext();
  9. //public string Greeting => "Welcome to Avalonia!";
  10. string adminkey;
  11. public string Adminkey { get => adminkey; set { adminkey = value; adminMethod(); } }
  12. private UserControl userControl = new ServiceListPage();
  13. public UserControl UserControl { get { return userControl; } set => this.RaiseAndSetIfChanged(ref userControl, value); }
  14. #region serviceList
  15. private ServiceListPageViewModel serviceListNewWM = new ServiceListPageViewModel(db);
  16. public ServiceListPageViewModel ServiceListPageWM { get => serviceListNewWM; set => serviceListNewWM = value; }
  17. #endregion
  18. void adminMethod()
  19. {
  20. if (Adminkey == "0000")
  21. {
  22. Models.Sevice.IsVisibleAdmin = true;
  23. UserControl = new ServiceListPage();
  24. }
  25. else
  26. {
  27. Models.Sevice.IsVisibleAdmin = false;
  28. UserControl = new ServiceListPage();
  29. }
  30. }
  31. }
  32. }