Implement ViewRouting.
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -194,7 +194,8 @@ namespace WalletWasabi.Fluent.Desktop
{
bool useGpuLinux = true;
- var result = AppBuilder.Configure<App>(()=>new App(Global));
+ var result = AppBuilder.Configure<App>(()=>new App(Global))
+ .UseReactiveUI();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{

ADD
WalletWasabi.Fluent/ViewModels/HomeViewModel.cs
+using ReactiveUI;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WalletWasabi.Fluent.ViewModels
+{
+ public class HomeViewModel : ViewModelBase, IRoutableViewModel
+ {
+ public HomeViewModel(IScreen screen) => HostScreen = screen;
+
+ // Reference to IScreen that owns the routable view model.
+ public IScreen HostScreen { get; }
+
+ // Unique identifier for the routable view model.
+ public string UrlPathSegment { get; } = Guid.NewGuid().ToString().Substring(0, 5);
+ }
+}

MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
+using Avalonia.Threading;
using NBitcoin;
using NBitcoin.Protocol;
using ReactiveUI;
using System;
using System.Collections.Generic;
+using System.Reactive;
using System.Text;
+using System.Threading.Tasks;
using WalletWasabi.Gui.ViewModels;
using Global = WalletWasabi.Gui.Global;
namespace WalletWasabi.Fluent.ViewModels
{
- public class MainViewModel : ViewModelBase
+ public class MainViewModel : ViewModelBase, IScreen
{
private Global _global;
private StatusBarViewModel _statusBar;
@@ -24,6 +27,13 @@ namespace WalletWasabi.Fluent.ViewModels
Network = global.Network;
StatusBar = new StatusBarViewModel(global.DataDir, global.Network, global.Config, global.HostedServices, global.BitcoinStore.SmartHeaderChain, global.Synchronizer, global.LegalDocuments);
+
+ Dispatcher.UIThread.Post(async () =>
+ {
+ await Task.Delay(5000);
+
+ Router.Navigate.Execute(new HomeViewModel(this));
+ });
}
public void Initialize()
@@ -36,6 +46,12 @@ namespace WalletWasabi.Fluent.ViewModels
}
}
+ public RoutingState Router { get; } = new RoutingState();
+
+ public ReactiveCommand<Unit, IRoutableViewModel> GoNext { get; }
+
+ public ReactiveCommand<Unit, Unit> GoBack => Router.NavigateBack;
+
public Network Network { get; }
public StatusBarViewModel StatusBar

ADD
WalletWasabi.Fluent/Views/HomeView.axaml
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="WalletWasabi.Fluent.Views.HomeView">
+ <StackPanel HorizontalAlignment="Center"
+ VerticalAlignment="Center">
+ <TextBlock Text="Hi, I'm the first view!" />
+ <TextBlock Text="{Binding UrlPathSegment}" />
+ </StackPanel>
+</UserControl>

ADD
WalletWasabi.Fluent/Views/HomeView.axaml.cs
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels;
+
+namespace WalletWasabi.Fluent.Views
+{
+ public class HomeView : UserControl, IViewFor<HomeViewModel>
+ {
+ public HomeView()
+ {
+ this.InitializeComponent();
+ }
+
+ public HomeViewModel ViewModel { get; set; }
+
+ object IViewFor.ViewModel { get; set; }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:vl="clr-namespace:WalletWasabi.Fluent"
xmlns:local="clr-namespace:WalletWasabi.Fluent.Views"
+ xmlns:rxui="clr-namespace:Avalonia.ReactiveUI;assembly=Avalonia.ReactiveUI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.MainView" TextBlock.Foreground="#A3A3A3">
<SplitView OpenPaneLength="220" CompactPaneLength="20" IsPaneOpen="True" DisplayMode="CompactInline">
</SplitView.Pane>
<DockPanel>
<local:StatusBar DockPanel.Dock="Bottom" DataContext="{Binding StatusBar}" VerticalAlignment="Bottom" Height="32" TextBlock.FontSize="12" />
- <Border Background="#212121" BoxShadow="0 1 4 #131313" />
+ <Border Background="#212121" BoxShadow="0 1 4 #131313">
+ <rxui:RoutedViewHost Router="{Binding Router}">
+ <rxui:RoutedViewHost.ViewLocator>
+ <vl:ScreenViewLocator />
+ </rxui:RoutedViewHost.ViewLocator>
+ <rxui:RoutedViewHost.DefaultContent>
+ <TextBlock Text="Default content"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center" />
+ </rxui:RoutedViewHost.DefaultContent>
+ </rxui:RoutedViewHost>
+ </Border>
</DockPanel>
</SplitView>
</UserControl>

Implement ViewRouting.