BaseViewModelExtension.cs 861 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using FWindSoft.Wpf;
  8. using FWindSoft.Wpf.Controls;
  9. namespace FWindSoft.MVVM
  10. {
  11. /// <summary>
  12. /// 基础视图
  13. /// </summary>
  14. public static class BaseViewModelExtension
  15. {
  16. public static Window GetWindow(this BaseViewModel vm)
  17. {
  18. var refView = vm.GetRefView();
  19. if (refView == null)
  20. return null;
  21. return refView.GetParentTypeSelf<Window>();
  22. ;
  23. }
  24. public static NavigationBar GetNavigationBar(this BaseViewModel vm)
  25. {
  26. var refView = vm.GetRefView();
  27. if (refView == null)
  28. return null;
  29. return refView.GetParentType<NavigationBar>();
  30. }
  31. }
  32. }