Fix UserControl Interaction

This commit is contained in:
Torben Nehmer 2024-09-23 21:28:33 +02:00
parent c2b265afd1
commit 782965ce49
3 changed files with 9 additions and 9 deletions

View File

@ -12,14 +12,16 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
{ {
public ViewModelActivator Activator { get; } = new ViewModelActivator(); public ViewModelActivator Activator { get; } = new ViewModelActivator();
[ObservableAsProperty] [Reactive]
private string _dbPath = ""; private string _dbPath;
[Reactive]
private BuColViewModel? _buColViewModel = new();
public MainWindowViewModel() public MainWindowViewModel()
{ {
using var db = Locator.Current.GetService<StarsDatabase>()!; using var db = Locator.Current.GetService<StarsDatabase>()!;
_dbPathHelper = Observable.Return(Path.GetFullPath(db.DbPath)) DbPath = Path.GetFullPath(db.DbPath);
.ToProperty(this, x => x.DbPath);
this.WhenActivated((CompositeDisposable disposables) => this.WhenActivated((CompositeDisposable disposables) =>
{ {

View File

@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
@ -12,13 +13,9 @@ public partial class BuColView : ReactiveUserControl<BuColViewModel>
{ {
public BuColView() public BuColView()
{ {
/*
this.WhenActivated(disposables => this.WhenActivated(disposables =>
{ {
}); });
*/
this.ViewModel = new BuColViewModel();
InitializeComponent(); InitializeComponent();
} }

View File

@ -26,7 +26,8 @@
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="BuCol"> <TabItem Header="BuCol">
<views:BuColView /> <views:BuColView x:Name="BuColView"
DataContext="{Binding BuColViewModel}" />
</TabItem> </TabItem>
</TabControl> </TabControl>
</Window> </Window>