MainWindowViewModel.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Avalonia.Controls;
  2. using ReactiveUI;
  3. namespace Prak12.ViewModels
  4. {
  5. public class MainWindowViewModel : ViewModelBase
  6. {
  7. public MainWindowViewModel()
  8. {
  9. ShowTeachersViewModel stvm = new ShowTeachersViewModel();
  10. stvm.ButtonAddNewTeacherWasPressed += ButtonAddNewTeacherWasPressed;
  11. UserControl = (new ViewLocator()).Build(stvm);
  12. }
  13. private void ButtonAddNewTeacherWasPressed()
  14. {
  15. AddTeachersViewModel atvm = new AddTeachersViewModel();
  16. atvm.AddNewTeacherPageWasClosed += AddNewTeacherPageWasClosed;
  17. UserControl = (new ViewLocator()).Build(atvm);
  18. }
  19. private void AddNewTeacherPageWasClosed()
  20. {
  21. ShowTeachersViewModel stvm = new ShowTeachersViewModel();
  22. stvm.ButtonAddNewTeacherWasPressed += ButtonAddNewTeacherWasPressed;
  23. UserControl = (new ViewLocator()).Build(stvm);
  24. }
  25. public Control UserControl
  26. {
  27. get => _userControl;
  28. set => this.RaiseAndSetIfChanged(ref _userControl, value);
  29. }
  30. private Control _userControl;
  31. }
  32. }