File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ public override void OnFrameworkInitializationCompleted() {
43
43
var vm = services . GetRequiredService < MainWindowViewModel > ( ) ;
44
44
if ( ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop ) {
45
45
desktop . MainWindow = new MainWindow {
46
- DataContext = vm
46
+ DataContext = vm ,
47
+ ServiceProvider = services
47
48
} ;
48
49
}
49
50
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public static void AddCommonServices(this IServiceCollection collection) {
28
28
collection . AddTransient < MainWindowViewModel > ( ) ;
29
29
collection . AddTransient < AccountViewModel > ( ) ;
30
30
collection . AddTransient < ChatViewModel > ( ) ;
31
+ collection . AddTransient < NewVersionWindowViewModel > ( ) ;
31
32
collection . AddTransient < ITwitchApiProxy , TwitchApiWrapper > ( TwitchApiWrapperFactory ) ;
32
33
}
33
34
Original file line number Diff line number Diff line change 6
6
using Avalonia . Controls ;
7
7
using Avalonia . Threading ;
8
8
9
+ using Microsoft . Extensions . DependencyInjection ;
10
+
9
11
using Nullinside . Api . Common . Desktop ;
10
12
#if ! DEBUG
11
13
using TwitchStreamingTools . ViewModels ;
@@ -17,6 +19,11 @@ namespace TwitchStreamingTools.Views;
17
19
/// The main application window.
18
20
/// </summary>
19
21
public partial class MainWindow : Window {
22
+ /// <summary>
23
+ /// The service provider for DI.
24
+ /// </summary>
25
+ public IServiceProvider ? ServiceProvider { get ; set ; }
26
+
20
27
/// <summary>
21
28
/// Initializes a new instance of the <see cref="MainWindow" /> class.
22
29
/// </summary>
@@ -53,11 +60,15 @@ protected override void OnInitialized() {
53
60
}
54
61
55
62
#if ! DEBUG
63
+ var vm = ServiceProvider ? . GetRequiredService < NewVersionWindowViewModel > ( ) ;
64
+ if ( null == vm ) {
65
+ return ;
66
+ }
67
+
68
+ vm . LocalVersion = localVersion ;
56
69
Dispatcher . UIThread . Post ( async ( ) => {
57
70
var versionWindow = new NewVersionWindow {
58
- DataContext = new NewVersionWindowViewModel {
59
- LocalVersion = localVersion
60
- }
71
+ DataContext = vm
61
72
} ;
62
73
63
74
await versionWindow . ShowDialog ( this ) ;
You can’t perform that action at this time.
0 commit comments