1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI/Screens/Root/RootView.axaml.cs
2023-10-18 23:13:57 +02:00

29 lines
688 B
C#

using System;
using System.Reactive.Disposables;
using Artemis.UI.Shared.Routing;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
using ReactiveUI;
namespace Artemis.UI.Screens.Root;
public partial class RootView : ReactiveUserControl<RootViewModel>
{
public RootView()
{
InitializeComponent();
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Screen).Subscribe(Navigate).DisposeWith(d));
}
private void Navigate(RoutableScreen? viewModel)
{
try
{
Dispatcher.UIThread.Invoke(() => RootFrame.NavigateFromObject(viewModel));
}
catch (Exception)
{
// ignored
}
}
}