Repository navigation
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
60 lines (51 loc) · 2.06 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
60 lines (51 loc) · 2.06 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
58
59
60
// Copyright (c) 2025 .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 Splat;
namespace ReactiveUI.Builder.WpfApp;
/// <summary>
/// Interaction logic for MainWindow.xaml.
/// </summary>
public partial class MainWindow : IViewFor<ViewModels.AppBootstrapper>
{
/// <summary>
/// The view model property.
/// </summary>
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(
nameof(ViewModel), typeof(ViewModels.AppBootstrapper), typeof(MainWindow), new PropertyMetadata(null));
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
InitializeComponent();
// Set up content host with routing
var host = new RoutedViewHost
{
Router = Locator.Current.GetService<IScreen>()!.Router,
DefaultContent = new System.Windows.Controls.TextBlock { Text = "Loading...", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center },
};
Content = host;
ViewModel = (ViewModels.AppBootstrapper)Locator.Current.GetService<IScreen>()!;
}
/// <summary>
/// Gets or sets the ViewModel corresponding to this specific View. This should be
/// a DependencyProperty if you're using XAML.
/// </summary>
public ViewModels.AppBootstrapper? ViewModel
{
get => (ViewModels.AppBootstrapper?)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
/// <summary>
/// Gets or sets the ViewModel corresponding to this specific View. This should be
/// a DependencyProperty if you're using XAML.
/// </summary>
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (ViewModels.AppBootstrapper?)value;
}
}