From 17f890cb9f3278dd24f4f47f7cf5836939a6928c Mon Sep 17 00:00:00 2001 From: Torben Nehmer Date: Fri, 13 Sep 2024 21:09:33 +0200 Subject: [PATCH] Move to ReactiveUI --- Stars Assistant/ViewModels/MainWindowViewModel.cs | 7 +++---- Stars Assistant/Views/MainWindow.axaml.cs | 8 +++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Stars Assistant/ViewModels/MainWindowViewModel.cs b/Stars Assistant/ViewModels/MainWindowViewModel.cs index 1a199f2..81bb73b 100644 --- a/Stars Assistant/ViewModels/MainWindowViewModel.cs +++ b/Stars Assistant/ViewModels/MainWindowViewModel.cs @@ -1,12 +1,11 @@ using System.Collections.ObjectModel; +using ReactiveUI; namespace StarsAssistant.ViewModels; -public partial class MainWindowViewModel : ViewModelBase +public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel { -#pragma warning disable CA1822 // Mark members as static - public string Greeting => "Welcome to Stars Assistant!"; -#pragma warning restore CA1822 // Mark members as static + public ViewModelActivator Activator { get; } = new ViewModelActivator(); public ObservableCollection Planets { get; } = PlanetViewModel.LoadAll(); diff --git a/Stars Assistant/Views/MainWindow.axaml.cs b/Stars Assistant/Views/MainWindow.axaml.cs index 2b09897..0742bf6 100644 --- a/Stars Assistant/Views/MainWindow.axaml.cs +++ b/Stars Assistant/Views/MainWindow.axaml.cs @@ -1,14 +1,16 @@ using Avalonia.Controls; -using Avalonia.Interactivity; +using Avalonia.ReactiveUI; using System.Diagnostics; using System; +using StarsAssistant.ViewModels; +using Avalonia.Markup.Xaml; namespace StarsAssistant.Views; -public partial class MainWindow : Window +public partial class MainWindow : ReactiveWindow { public MainWindow() { - InitializeComponent(); + AvaloniaXamlLoader.Load(this); } } \ No newline at end of file