ExcelHelper/Views/ViewModels/MainViewModel.cs

35 lines
932 B
C#

using System.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ExcelHelper.Views.Pages;
namespace ExcelHelper.Views.ViewModels
{
public partial class MainViewModel : ObservableObject, IViewModel
{
/// <summary>
/// 异常信息
/// </summary>
[ObservableProperty]
private string _errorMessage;
[RelayCommand]
private void OnSideMenuSelect(string itemTag)
{
Trace.WriteLine($"OnSideMenuSelect -> {itemTag}");
var targetPage = itemTag switch
{
"ImportExcelPage" => typeof(ImportExcelPage),
"DataListPage" => typeof(DataListPage),
_ => null
};
if (targetPage != null)
{
App.AppHost.Get<Services.NavigationService>().NavigateTo(targetPage);
}
}
}
}