ExcelHelper/MainWindow.xaml.cs

38 lines
1.0 KiB
C#

using System.Windows;
using CommunityToolkit.Mvvm.Messaging;
using ExcelHelper.Message;
using ExcelHelper.Services;
using ExcelHelper.Views;
using ExcelHelper.Views.ViewModels;
namespace ExcelHelper;
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window, IView
{
private readonly MainViewModel ViewModel;
public MainWindow(MainViewModel viewModel, NavigationService navigationService)
{
InitializeComponent();
DataContext = ViewModel = viewModel;
navigationService.InitForFrame(MainFrame);
WeakReferenceMessenger.Default.Register<ErrorDialogMessage>(this, (r, message) =>
{
if (message.Value != null)
{
ViewModel.ErrorMessage = message.Value;
MessageDialog.Visibility = Visibility.Visible;
}
});
}
private void DialogCloseBtn_Click(object sender, System.Windows.RoutedEventArgs e)
{
MessageDialog.Visibility = System.Windows.Visibility.Collapsed;
}
}