mirror of
https://onedev.site.tesses.net/crosslang/crosslangdevstudio
synced 2026-02-08 09:15:45 +00:00
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System.Threading.Tasks;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Platform.Storage;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using CrossLangDevStudio.Messages;
|
|
using CrossLangDevStudio.ViewModels;
|
|
|
|
namespace CrossLangDevStudio.Views;
|
|
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (Design.IsDesignMode)
|
|
return;
|
|
|
|
// Whenever 'Send(new PurchaseAlbumMessage())' is called, invoke this callback on the MainWindow instance:
|
|
WeakReferenceMessenger.Default.Register<MainWindow, NewProjectMessage>(this, static (w, m) =>
|
|
{
|
|
// Create an instance of MusicStoreWindow and set MusicStoreViewModel as its DataContext.
|
|
var dialog = new NewProjectDialog
|
|
{
|
|
DataContext = new NewProjectDialogViewModel()
|
|
};
|
|
// Show dialog window and reply with returned AlbumViewModel or null when the dialog is closed.
|
|
m.Reply(dialog.ShowDialog<string?>(w));
|
|
});
|
|
WeakReferenceMessenger.Default.Register<MainWindow, GetWindowMessage>(this, static (w, m) =>
|
|
{
|
|
m.Reply(w);
|
|
}
|
|
);
|
|
|
|
}
|
|
} |