Update Avalonia to preview, Minor Refactor

- 0.9.0-preview7
- Set MainWindow's DataContext to itself
This commit is contained in:
adroslice 2019-11-13 20:40:30 +01:00
parent 664acd3249
commit 0c0617df24
5 changed files with 40 additions and 21 deletions

23
BFR.sln
View File

@ -1,8 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BFR", "BFR\BFR.csproj", "{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -12,7 +14,24 @@ Global
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|x64.ActiveCfg = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|x64.Build.0 = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|x86.ActiveCfg = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Debug|x86.Build.0 = Debug|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|Any CPU.Build.0 = Release|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|x64.ActiveCfg = Release|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|x64.Build.0 = Release|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|x86.ActiveCfg = Release|Any CPU
{9D0FCB76-B39F-4986-BE64-938CA8F0D64D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5A7A7691-987D-4C2F-AC95-7524A6F2F4A4}
EndGlobalSection
EndGlobal

View File

@ -1,13 +1,23 @@
using Avalonia;
using Avalonia.Markup.Xaml;
using Avalonia.Controls.ApplicationLifetimes;
namespace BFR
{
public class App : Application
{
public override void Initialize()
{
public override void Initialize() =>
AvaloniaXamlLoader.Load(this);
public override void OnFrameworkInitializationCompleted()
{
switch (ApplicationLifetime)
{
case IClassicDesktopStyleApplicationLifetime desktop:
desktop.MainWindow = new MainWindow();
break;
}
base.OnFrameworkInitializationCompleted();
}
}
}
}

View File

@ -12,7 +12,7 @@
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.8.2" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.2" />
<PackageReference Include="Avalonia" Version="0.9.0-preview7" />
<PackageReference Include="Avalonia.Desktop" Version="0.9.0-preview7" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,3 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
@ -6,14 +5,13 @@ namespace BFR
{
public class MainWindow : Window
{
public MainWindow()
{
public MainWindow() =>
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
DataContext = this;
}
}
}

View File

@ -1,5 +1,4 @@
using System;
using Avalonia;
using Avalonia;
using Avalonia.Logging.Serilog;
namespace BFR
@ -9,19 +8,12 @@ namespace BFR
// 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().Start(AppMain, args);
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()
.LogToDebug();
// Your application's entry point. Here you can initialize your MVVM framework, DI
// container, etc.
private static void AppMain(Application app, string[] args)
{
app.Run(new MainWindow());
}
}
}