using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.UI.Xaml.Navigation; using XFEExtension.NetCore.WinUIHelper.Interface.Services; using XFEExtension.NetCore.WinUIHelper.Utilities; namespace ChaoXingAutoClass.ViewModels { public partial class AppShellPageViewModel : ViewModelBase { [ObservableProperty] public partial bool CanGoBack { get; set; } [ObservableProperty] public partial string UserName { get; set; } = "学习账号"; public IDialogService DialogService { get; set; } = ServiceManager.GetService(); public INavigationViewService NavigationViewService { get; set; } = ServiceManager.GetService(); public IMessageService MessageService { get; set; } = ServiceManager.GetService(); public ILoadingService LoadingService { get; set; } = ServiceManager.GetService(); public AppShellPageViewModel() { NavigationViewService.NavigationService.Navigated += NavigationService_Navigated; } private void NavigationService_Navigated(object? sender, NavigationEventArgs e) => CanGoBack = NavigationViewService.NavigationService.CanGoBack; } }