From 782965ce49cbcbf80af2aed78fcc1cad06177e69 Mon Sep 17 00:00:00 2001 From: Torben Nehmer Date: Mon, 23 Sep 2024 21:28:33 +0200 Subject: [PATCH] Fix UserControl Interaction --- Stars Assistant/ViewModels/MainWindowViewModel.cs | 10 ++++++---- Stars Assistant/Views/BuColView.axaml.cs | 5 +---- Stars Assistant/Views/MainWindow.axaml | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Stars Assistant/ViewModels/MainWindowViewModel.cs b/Stars Assistant/ViewModels/MainWindowViewModel.cs index 4e6184f..1eaf568 100644 --- a/Stars Assistant/ViewModels/MainWindowViewModel.cs +++ b/Stars Assistant/ViewModels/MainWindowViewModel.cs @@ -12,14 +12,16 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel { public ViewModelActivator Activator { get; } = new ViewModelActivator(); - [ObservableAsProperty] - private string _dbPath = ""; + [Reactive] + private string _dbPath; + + [Reactive] + private BuColViewModel? _buColViewModel = new(); public MainWindowViewModel() { using var db = Locator.Current.GetService()!; - _dbPathHelper = Observable.Return(Path.GetFullPath(db.DbPath)) - .ToProperty(this, x => x.DbPath); + DbPath = Path.GetFullPath(db.DbPath); this.WhenActivated((CompositeDisposable disposables) => { diff --git a/Stars Assistant/Views/BuColView.axaml.cs b/Stars Assistant/Views/BuColView.axaml.cs index 246a676..d6afd39 100644 --- a/Stars Assistant/Views/BuColView.axaml.cs +++ b/Stars Assistant/Views/BuColView.axaml.cs @@ -1,3 +1,4 @@ +using System.ComponentModel.DataAnnotations; using System.Reactive.Disposables; using Avalonia; using Avalonia.Controls; @@ -12,13 +13,9 @@ public partial class BuColView : ReactiveUserControl { public BuColView() { - /* this.WhenActivated(disposables => { }); - */ - - this.ViewModel = new BuColViewModel(); InitializeComponent(); } diff --git a/Stars Assistant/Views/MainWindow.axaml b/Stars Assistant/Views/MainWindow.axaml index 2185686..b007376 100644 --- a/Stars Assistant/Views/MainWindow.axaml +++ b/Stars Assistant/Views/MainWindow.axaml @@ -26,7 +26,8 @@ - +