-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
57 lines (50 loc) · 1.92 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
57 lines (50 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2009-2026 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ReactiveUI.Builder.WpfApp.ViewModels;
using Splat;
namespace ReactiveUI.Builder.WpfApp;
/// <summary>The application shell window; hosts the router through a <see cref="RoutedViewHost"/>.</summary>
public partial class MainWindow : IViewFor<AppBootstrapper>
{
/// <summary>Identifies the <see cref="ViewModel"/> dependency property.</summary>
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(
nameof(ViewModel),
typeof(AppBootstrapper),
typeof(MainWindow),
new(null));
/// <summary>Initializes a new instance of the <see cref="MainWindow"/> class.</summary>
public MainWindow()
{
InitializeComponent();
var screen = (AppBootstrapper)Locator.Current.GetService<IScreen>()!;
ViewModel = screen;
Content = new RoutedViewHost
{
Router = screen.Router,
DefaultContent = new TextBlock
{
Text = "Loading…",
Foreground = Brushes.Gray,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
};
}
/// <summary>Gets or sets the root screen that backs this shell.</summary>
public AppBootstrapper? ViewModel
{
get => (AppBootstrapper?)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
/// <inheritdoc/>
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (AppBootstrapper?)value;
}
}