Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

556 compatibility inquiry avaloniaui #851

Merged
merged 169 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
33804c0
Add avalonia ui to current code base
vb2ae May 8, 2022
632eebd
Working on feature project
vb2ae May 8, 2022
7a5a32b
avalonia changes for navigation and features app
vb2ae May 11, 2022
9d1ead5
features app for avalonia
vb2ae May 11, 2022
42a84b6
avalonia ui
vb2ae Jul 3, 2022
042a3e1
merge from master
vb2ae Jul 4, 2022
2e40518
Handle application lifetime events.
Jul 16, 2022
0342779
fix build
vb2ae Jul 19, 2022
1b63082
fix build
vb2ae Jul 20, 2022
857437a
Expose ShowDialogAsync in IWindowManager.
Jul 26, 2022
5abe5b6
Fix bootstrapper.
Jul 26, 2022
9915983
update xamarin forms version
vb2ae Jul 27, 2022
a6f1282
fix build errors
vb2ae Jul 27, 2022
b972493
Merge pull request #816 from Stannieman/556-add_showdialogasync_to_iw…
vb2ae Aug 12, 2022
aaa9735
Merge pull request #815 from Stannieman/556-handle-lifetime-events
vb2ae Aug 12, 2022
e675ca9
update global json
vb2ae Nov 25, 2022
290b6d6
Merge in master
vb2ae Nov 25, 2022
5682955
update avalonia ui version
vb2ae Nov 25, 2022
94e9f51
upgrade xunit version
vb2ae Nov 25, 2022
83e9b88
Added Reactive navigation
vb2ae Nov 27, 2022
19877a3
merge remove .net 5
vb2ae Nov 27, 2022
61012cc
more avalonia
vb2ae Dec 6, 2022
9095057
avalonia updates
vb2ae Jan 13, 2023
cbfa83f
avalonia features app
vb2ae Feb 5, 2023
23237fa
Update to Avalonia 11.0.0-preview5.
Feb 11, 2023
eb41df3
Merge pull request #845 from Stannieman/feature/556-Update_to_Avaloni…
vb2ae Feb 12, 2023
41d486e
navigation changes
vb2ae Feb 12, 2023
7db6f34
merged in changes
vb2ae Feb 13, 2023
b659a67
Merge tag '5.0.31-beta' into 556-compatibility-inquiry-avaloniaui
danwalmsley Mar 16, 2023
5ff0f92
remove reactiveui (shouldnt depend on another mvvm framework)
danwalmsley Mar 16, 2023
8ac6d7a
add demonstration of Message.Atach
danwalmsley Mar 16, 2023
9092c55
remove deleted project from the solution.
danwalmsley Mar 16, 2023
94771b9
fix build
danwalmsley Mar 16, 2023
18904d8
remove accidentally added test project.
danwalmsley Mar 16, 2023
d0d8965
Create default arguments depending on actual InitializeComponent para…
Mar 16, 2023
216a743
update microsoft test sdk
vb2ae Mar 18, 2023
4f831c4
merge from online
vb2ae Mar 19, 2023
be3c828
update global json
vb2ae Mar 19, 2023
74bc7f8
Dont need to manually call InitialiseComponent on Avalonia
danwalmsley Mar 20, 2023
94cf685
fix features project build and update to 11.0
danwalmsley Mar 20, 2023
6eed38b
add missing xmlns attribute.
danwalmsley Mar 20, 2023
a9d61cd
Use Avalonia metadata attributes.
grokys Mar 20, 2023
925596a
Forgot to commit the change to the project file.
grokys Mar 20, 2023
fb767ff
Bind the view model after initialize.
grokys Mar 20, 2023
591a526
Change ShowDialogAsync return type.
grokys Mar 21, 2023
617fb57
update to avalonia 11 p6
Mar 22, 2023
c18caa2
Merge pull request #847 from Stannieman/feature/Support_InitializeCom…
vb2ae Mar 23, 2023
25fcca0
Merge pull request #846 from AvaloniaUI/556-compatibility-inquiry-ava…
vb2ae Mar 23, 2023
8153230
Merge branch '556-compatibility-inquiry-avaloniaui' of https://github…
vb2ae Mar 23, 2023
5556d99
update avalonia
Mar 23, 2023
649886f
make OnUIThreadAsync wait for the wrapped task.
Mar 24, 2023
4a45282
implement GetViewCloseAction correctly for Avalonia so that it calls …
Mar 24, 2023
ba92c42
Merge pull request #850 from AvaloniaUI/556-compatibility-inquiry-ava…
vb2ae Mar 24, 2023
75cda8b
Merge branch '556-compatibility-inquiry-avaloniaui' of https://github…
vb2ae Mar 25, 2023
ad228b0
Avalonia changes
vb2ae Apr 2, 2023
11f09b2
update theme package
vb2ae Apr 2, 2023
be89b49
fix reference path
vb2ae Apr 2, 2023
a5c370d
fix code ql
vb2ae Apr 2, 2023
ec55484
Switch ItemsControl.Items property to ItemsSource for compatibility w…
Apr 7, 2023
8c36add
Merge pull request #854 from Stannieman/feature/Switch_Items_to_Items…
vb2ae Apr 8, 2023
81be615
update avalonia.
danwalmsley Apr 25, 2023
a262a1c
remove code incompatible with avalonia
danwalmsley Apr 25, 2023
9424c80
Merge pull request #856 from AvaloniaUI/update-avalonia
vb2ae Apr 26, 2023
94111f9
feature app changes
vb2ae Apr 26, 2023
a5c35e3
Change features.avalonia to use shared viewmodels
vb2ae May 6, 2023
e3cf787
fixed some code suggestions
vb2ae May 6, 2023
5a44edf
Add avalonia ui to current code base
vb2ae May 8, 2022
8d177f7
Working on feature project
vb2ae May 8, 2022
48de3b6
avalonia changes for navigation and features app
vb2ae May 11, 2022
10237ad
features app for avalonia
vb2ae May 11, 2022
595b413
avalonia ui
vb2ae Jul 3, 2022
b891467
fix build
vb2ae Jul 19, 2022
f56334a
fix build
vb2ae Jul 20, 2022
32e9ff4
update xamarin forms version
vb2ae Jul 27, 2022
e885f75
fix build errors
vb2ae Jul 27, 2022
071e025
Expose ShowDialogAsync in IWindowManager.
Jul 26, 2022
db2c20a
Fix bootstrapper.
Jul 26, 2022
22e65e6
Handle application lifetime events.
Jul 16, 2022
5ff6c43
update avalonia ui version
vb2ae Nov 25, 2022
2b9be83
upgrade xunit version
vb2ae Nov 25, 2022
70ec614
Added Reactive navigation
vb2ae Nov 27, 2022
4704194
more avalonia
vb2ae Dec 6, 2022
254517e
avalonia updates
vb2ae Jan 13, 2023
87b504d
avalonia features app
vb2ae Feb 5, 2023
7d1aacb
navigation changes
vb2ae Feb 12, 2023
e50927d
Update to Avalonia 11.0.0-preview5.
Feb 11, 2023
1f0c383
update global json
vb2ae Mar 19, 2023
d7eb42d
Create default arguments depending on actual InitializeComponent para…
Mar 16, 2023
ffb4f17
remove reactiveui (shouldnt depend on another mvvm framework)
danwalmsley Mar 16, 2023
21e00c2
add demonstration of Message.Atach
danwalmsley Mar 16, 2023
11d2151
fix build
danwalmsley Mar 16, 2023
030c608
remove accidentally added test project.
danwalmsley Mar 16, 2023
d8dec64
Dont need to manually call InitialiseComponent on Avalonia
danwalmsley Mar 20, 2023
e1982b2
fix features project build and update to 11.0
danwalmsley Mar 20, 2023
0c8e4b5
add missing xmlns attribute.
danwalmsley Mar 20, 2023
2d2d937
Use Avalonia metadata attributes.
grokys Mar 20, 2023
e1e73dd
Forgot to commit the change to the project file.
grokys Mar 20, 2023
f962344
Bind the view model after initialize.
grokys Mar 20, 2023
94c26c9
Change ShowDialogAsync return type.
grokys Mar 21, 2023
26a35b3
update to avalonia 11 p6
Mar 22, 2023
5f259d7
update avalonia
Mar 23, 2023
56f5aa9
make OnUIThreadAsync wait for the wrapped task.
Mar 24, 2023
0aab4cb
implement GetViewCloseAction correctly for Avalonia so that it calls …
Mar 24, 2023
5562f7e
Avalonia changes
vb2ae Apr 2, 2023
3090719
update theme package
vb2ae Apr 2, 2023
dc95a4e
fix reference path
vb2ae Apr 2, 2023
7941e9a
fix code ql
vb2ae Apr 2, 2023
6911022
Switch ItemsControl.Items property to ItemsSource for compatibility w…
Apr 7, 2023
6bec738
feature app changes
vb2ae Apr 26, 2023
2f09d0d
update avalonia.
danwalmsley Apr 25, 2023
bb3ae78
fixed some code suggestions
vb2ae May 6, 2023
71d3ac1
rebase
vb2ae May 6, 2023
051db86
rebase
vb2ae May 6, 2023
0493d83
Fixed conflict
vb2ae May 7, 2023
0076a96
fix setup app
vb2ae May 7, 2023
b513157
update nuget to latest version in setup samples
vb2ae May 9, 2023
038b5ac
fix setup projects
vb2ae May 9, 2023
6a127e7
Update Avalonia to 11 preview 8.
May 26, 2023
0fbcd74
Fix some warnings + remove superfluous #if AVALONIA
May 26, 2023
495804b
Merge pull request #860 from Stannieman/feature/Update_Avalonia_to_11…
vb2ae May 29, 2023
75b926c
Merge pull request #861 from Stannieman/feature/Various_cleanups
vb2ae May 29, 2023
d9fd41d
bug fixes
vb2ae May 29, 2023
23f892c
Merge in latest
vb2ae May 29, 2023
1b0a526
rename caliburn frame to navigation frame
vb2ae May 29, 2023
cd63dfa
use crossplatform viewmodels
vb2ae May 29, 2023
1e28161
Update nuget for avalaonia in setup app
vb2ae May 29, 2023
f78afc3
update to avvalonia ui 11 rc
vb2ae Jun 2, 2023
ac64bfd
fix code ql scan
vb2ae Jun 2, 2023
364372d
update codeql action to use global.json file for .net version
vb2ae Jun 4, 2023
95bf2fc
update to dotnet install version 3
vb2ae Jun 4, 2023
930ba71
update codeql actions to latest version
vb2ae Jun 4, 2023
d9abcae
fix java install in codeql action
vb2ae Jun 4, 2023
fc1fdfc
Avalonia ui RC1.1
vb2ae Jun 24, 2023
77fcf41
change event to loaded
vb2ae Jun 25, 2023
f6fe78e
update for avalonia rc 2.2
vb2ae Jul 4, 2023
d3c737d
Update Avalonia to 11.0.0.
Jul 6, 2023
94e6c01
Merge pull request #865 from Stannieman/feature/Update_Avalonia_to_11…
vb2ae Jul 12, 2023
160c688
update to avalonia ui 11
vb2ae Jul 12, 2023
ec0c153
Run CanCloseAsync with DispatcherPriority Input.
Aug 4, 2023
4e93fea
Merge pull request #867 from Stannieman/Fix_crash_when_closing_window…
vb2ae Sep 19, 2023
10c940a
merge from master
vb2ae Nov 3, 2024
cb3cce7
fix unit tests for avalonia platform
vb2ae Nov 4, 2024
1e991e9
Fixed unit tests for binding scope
vb2ae Nov 5, 2024
6c8bca8
codeql suggestions
vb2ae Nov 6, 2024
1d28ada
merge in latest
vb2ae Nov 6, 2024
c303041
Navigation service improvements
vb2ae Nov 6, 2024
686468c
code ql fixes
vb2ae Nov 6, 2024
58750db
Fix codeql errors
vb2ae Nov 6, 2024
9d5dc16
fix more codeql issues
vb2ae Nov 6, 2024
2e61bb1
code ql fixes
vb2ae Nov 6, 2024
22e97bf
Refactor and improve code quality in multiple files
vb2ae Nov 6, 2024
7f13bca
Fix invalid format issue in code ql
vb2ae Nov 7, 2024
da0246b
fix coded ql issue
vb2ae Nov 8, 2024
01dd0c0
fix codeql errors
vb2ae Nov 8, 2024
395dc3d
codeql issues
vb2ae Nov 8, 2024
58c5ab4
more codeql
vb2ae Nov 8, 2024
ef74c67
Add some more tests
vb2ae Nov 8, 2024
8b54923
remove code coverage files
vb2ae Nov 8, 2024
b7ccf69
Add logging, refactor methods, and update event handling
vb2ae Nov 11, 2024
1e9cacf
add windows platform to build
vb2ae Nov 11, 2024
468d1c2
Merge branch 'master' into 556-compatibility-inquiry-avaloniaui
vb2ae Nov 11, 2024
2c02446
merge in latest from master
vb2ae Nov 21, 2024
3ada2e4
Update Avalonia packages and simplify transition condition
vb2ae Dec 12, 2024
957867a
merge in latest
vb2ae Dec 12, 2024
da442e0
Merge in latest
vb2ae Dec 12, 2024
1425bb0
merge in latest
vb2ae Dec 14, 2024
e6df13a
merge in latest
vb2ae Dec 14, 2024
19153bb
Improve null safety and simplify type casting
vb2ae Dec 14, 2024
282dc22
Refactor method parameters and rename async method
vb2ae Dec 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
454 changes: 454 additions & 0 deletions samples/features/Features.Avalonia/.gitignore

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions samples/features/Features.Avalonia/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Features.Avalonia.App">
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
20 changes: 20 additions & 0 deletions samples/features/Features.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace Features.Avalonia
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
base.OnFrameworkInitializationCompleted();
new Bootstrapper();
}
}
}
65 changes: 65 additions & 0 deletions samples/features/Features.Avalonia/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using Caliburn.Micro;
using Features.CrossPlatform.ViewModels;


namespace Features.Avalonia
{
public class Bootstrapper : BootstrapperBase
{
private readonly SimpleContainer _container;

public Bootstrapper()
{
LogManager.GetLog = type => new DebugLog(type);
_container = new SimpleContainer();
_container.Instance(_container);

Initialize();

(DisplayRootViewFor<ShellViewModel>()).ConfigureAwait(false);
}

protected override void Configure()
{
_container
.Singleton<IWindowManager, WindowManager>()
.Singleton<IEventAggregator, EventAggregator>();

_container
.PerRequest<ShellViewModel>()
.PerRequest<MenuViewModel>()
.PerRequest<BindingsViewModel>()
.PerRequest<ActionsViewModel>()
.PerRequest<CoroutineViewModel>()
.PerRequest<ExecuteViewModel>()
.PerRequest<EventAggregationViewModel>()
.PerRequest<DesignTimeViewModel>()
.PerRequest<ConductorViewModel>()
.PerRequest<BubblingViewModel>()
.PerRequest<NavigationSourceViewModel>()
.PerRequest<NavigationTargetViewModel>();
}


protected override object GetInstance(Type service, string key)
{
return _container.GetInstance(service, key);
}

protected override IEnumerable<object> GetAllInstances(Type service)
{
return _container.GetAllInstances(service);
}

protected override void BuildUp(object instance)
{
_container.BuildUp(instance);
}


}
}
54 changes: 54 additions & 0 deletions samples/features/Features.Avalonia/Features.Avalonia.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<AvaloniaNameGeneratorIsEnabled>false</AvaloniaNameGeneratorIsEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>AVALONIA</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>AVALONIA</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.2" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.2" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.2.2" />

<PackageReference Include="Avalonia.Themes.FLuent" Version="11.2.2" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.2.0.1" />
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.2.0.1" />
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro.Avalonia">
<HintPath>..\..\..\bin\Caliburn.Micro.Avalonia\Release\net8.0\Caliburn.Micro.Avalonia.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Core">
<HintPath>..\..\..\bin\Caliburn.Micro.Avalonia\Release\net8.0\Caliburn.Micro.Core.dll</HintPath>
</Reference>
</ItemGroup>


<ItemGroup>
<Compile Update="Views\ActionsView.axaml.cs">
<DependentUpon>ActionsView.axaml</DependentUpon>
</Compile>
<Compile Update="Views\BindingsView.axaml.cs">
<DependentUpon>BindingsView.axaml</DependentUpon>
</Compile>
</ItemGroup>


<Import Project="..\Features.CrossPlatform.Shared\Features.CrossPlatform.Shared.projitems" Label="Shared" />
</Project>
15 changes: 15 additions & 0 deletions samples/features/Features.Avalonia/Lipsum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace Features.Avalonia
{
public static class Lipsum
{
private const string Base = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ullamcorper ligula quis nisl varius, vitae tincidunt libero dapibus. Nunc vel nunc elit. Etiam aliquet nec ligula eget pretium. Ut non arcu sem. Fusce et auctor dui. Mauris in lorem sit amet massa varius finibus et at metus. Aliquam non mi non justo malesuada suscipit. Etiam tincidunt ullamcorper sodales. Suspendisse potenti. Etiam ut fringilla risus. Cras varius neque metus, ac laoreet mauris commodo a.";
private static readonly Random Random = new Random();

public static string Get(int? length = null)
{
return Base.Substring(0, Random.Next(length ?? Base.Length));
}
}
}
14 changes: 14 additions & 0 deletions samples/features/Features.Avalonia/Messages/SimpleMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Features.Avalonia.Messages
{
public class SimpleMessage
{
public SimpleMessage(string text)
{
Text = text;
}

public string Text { get; }
}
}
22 changes: 22 additions & 0 deletions samples/features/Features.Avalonia/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using System;

namespace Features.Avalonia
{
internal class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
}
}
27 changes: 27 additions & 0 deletions samples/features/Features.Avalonia/Results/MessageDialogResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Caliburn.Micro;
using MsBox.Avalonia;


namespace Features.Avalonia.Results
{
public class MessageDialogResult : ResultBase
{
private readonly string content;
private readonly string title;

public MessageDialogResult(string content, string title)
{
this.content = content;
this.title = title;
}

public override async void Execute(CoroutineExecutionContext context)
{
var dialog = MessageBoxManager
.GetMessageBoxStandard(title, content);

await dialog.ShowAsync();
OnCompleted();
}
}
}
38 changes: 38 additions & 0 deletions samples/features/Features.Avalonia/Results/ResultBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using Caliburn.Micro;

namespace Features.Avalonia.Results
{
public abstract class ResultBase : IResult
{
public abstract void Execute(CoroutineExecutionContext context);

public event EventHandler<ResultCompletionEventArgs> Completed = delegate { };

protected virtual void OnCompleted()
{
OnCompleted(new ResultCompletionEventArgs());
}

protected virtual void OnError(Exception error)
{
OnCompleted(new ResultCompletionEventArgs
{
Error = error
});
}

protected virtual void OnCancelled()
{
OnCompleted(new ResultCompletionEventArgs
{
WasCancelled = true
});
}

protected virtual void OnCompleted(ResultCompletionEventArgs e)
{
Caliburn.Micro.Execute.OnUIThread(() => Completed(this, e));
}
}
}
33 changes: 33 additions & 0 deletions samples/features/Features.Avalonia/Results/VisualStateResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Avalonia.Controls;
using Caliburn.Micro;

namespace Features.Avalonia.Results
{
public class VisualStateResult : ResultBase
{
public VisualStateResult(string stateName, bool useTransitions = true)
{
StateName = stateName;
UseTransitions = useTransitions;
}

public string StateName { get; }

public bool UseTransitions { get; }

public override void Execute(CoroutineExecutionContext context)
{

if (!(context.View is Control))
throw new System.InvalidOperationException("View must be a Control to use VisualStateResult");

var view = (Control)context.View;
view.Classes.Clear();
view.Classes.Add(StateName);
OnCompleted();
}


}
}

17 changes: 17 additions & 0 deletions samples/features/Features.Avalonia/TaskHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Features.Avalonia
{
/// <summary>
/// Helper class to manage differences in the Task libraries between versions
/// </summary>
public static class TaskHelper
{

public static Task<T> FromResult<T>(T result) => Task.FromResult(result);
public static Task Delay(int milliseconds) => Task.Delay(milliseconds);

}
}
50 changes: 50 additions & 0 deletions samples/features/Features.Avalonia/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Threading;
using System.Threading.Tasks;
using Caliburn.Micro;

namespace Features.CrossPlatform.ViewModels
{
public class ShellViewModel : Screen, IHandle<FeatureViewModel>
{
private readonly IEventAggregator _eventAggregator;
private SimpleContainer _container;
private INavigationService _navigationService;

public ShellViewModel(IEventAggregator eventAggregator, SimpleContainer container)

Check warning on line 13 in samples/features/Features.Avalonia/ViewModels/ShellViewModel.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_navigationService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
_eventAggregator = eventAggregator;
_eventAggregator.SubscribeOnPublishedThread(this);
_container = container;
}

public async Task HandleAsync(FeatureViewModel message, CancellationToken cancellationToken)
{
await _navigationService.NavigateToViewModelAsync(message.ViewModel);
}

protected override async Task OnInitializedAsync(CancellationToken cancellationToken)
{
await base.OnInitializedAsync(cancellationToken);

GoHome();
}

public void GoHome()
{
var menuVM = _container.GetInstance<MenuViewModel>();
if (_navigationService != null)
{
_navigationService.NavigateToViewModelAsync(typeof(MenuViewModel));
}
}

public async void NavReady(NavigationFrame frame)
{
_navigationService = frame as INavigationService;

_container.Instance(_navigationService);
await _navigationService.NavigateToViewModelAsync(typeof(MenuViewModel));
}
}

}
Loading
Loading