MainWindowViewModel.cs 868 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Avalonia.Controls;
  2. using ReactiveUI;
  3. namespace AvaloniaApplication10.ViewModels
  4. {
  5. public class MainWindowViewModel : ViewModelBase
  6. {
  7. UserControl _us = new Page1();
  8. public UserControl Us {
  9. get => _us;
  10. set => this.RaiseAndSetIfChanged(ref _us, value);
  11. }
  12. Page1ViewModel _page1VM = new Page1ViewModel();
  13. public Page1ViewModel Page1VM
  14. {
  15. get => _page1VM;
  16. set => _page1VM = value;
  17. }
  18. public Page2ViewModel Page2VM
  19. {
  20. get => page2VM;
  21. set => page2VM = value;
  22. }
  23. Page2ViewModel page2VM = new Page2ViewModel();
  24. public void ToPage2()
  25. {
  26. Us = new Page2();
  27. }
  28. public void ToPage1()
  29. {
  30. Us = new Page1();
  31. }
  32. }
  33. }