From c80a75e10acbe8ce322b5ed1eff4e9e807d6408e Mon Sep 17 00:00:00 2001 From: Nicolai Henriksen Date: Sat, 25 Feb 2023 10:31:19 +0100 Subject: [PATCH 01/11] Add sample project reproducing the issue --- Directory.packages.props | 4 +- MDIX-Testing/App.xaml | 13 +++++ MDIX-Testing/App.xaml.cs | 42 ++++++++++++++++ MDIX-Testing/AssemblyInfo.cs | 10 ++++ MDIX-Testing/Dialog.xaml | 22 +++++++++ MDIX-Testing/Dialog.xaml.cs | 11 +++++ MDIX-Testing/InfoView.xaml | 13 +++++ MDIX-Testing/InfoView.xaml.cs | 26 ++++++++++ MDIX-Testing/MDIX-Testing.csproj | 22 +++++++++ MDIX-Testing/MainWindow.xaml | 74 +++++++++++++++++++++++++++++ MDIX-Testing/MainWindow.xaml.cs | 9 ++++ MDIX-Testing/MainWindowViewModel.cs | 36 ++++++++++++++ MaterialDesignToolkit.Full.sln | 19 ++++++++ 13 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 MDIX-Testing/App.xaml create mode 100644 MDIX-Testing/App.xaml.cs create mode 100644 MDIX-Testing/AssemblyInfo.cs create mode 100644 MDIX-Testing/Dialog.xaml create mode 100644 MDIX-Testing/Dialog.xaml.cs create mode 100644 MDIX-Testing/InfoView.xaml create mode 100644 MDIX-Testing/InfoView.xaml.cs create mode 100644 MDIX-Testing/MDIX-Testing.csproj create mode 100644 MDIX-Testing/MainWindow.xaml create mode 100644 MDIX-Testing/MainWindow.xaml.cs create mode 100644 MDIX-Testing/MainWindowViewModel.cs diff --git a/Directory.packages.props b/Directory.packages.props index 3aacd77f87..3056e29f12 100644 --- a/Directory.packages.props +++ b/Directory.packages.props @@ -26,5 +26,7 @@ + + - \ No newline at end of file + diff --git a/MDIX-Testing/App.xaml b/MDIX-Testing/App.xaml new file mode 100644 index 0000000000..87d596520d --- /dev/null +++ b/MDIX-Testing/App.xaml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/MDIX-Testing/App.xaml.cs b/MDIX-Testing/App.xaml.cs new file mode 100644 index 0000000000..de95bc9617 --- /dev/null +++ b/MDIX-Testing/App.xaml.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System.Windows; + +namespace MDIX_Testing; + +public partial class App : Application +{ + public static IHost? AppHost { get; private set; } + + public App() + { + AppHost = Host.CreateDefaultBuilder() + .ConfigureServices((hostContext, services) => + { + services.AddSingleton(services => new MainWindow() + { + DataContext = services.GetRequiredService() + }); + + services.AddSingleton(); + }) + .Build(); + } + + protected override async void OnStartup(StartupEventArgs e) + { + await AppHost!.StartAsync(); + + var startupForm = AppHost.Services.GetRequiredService(); + startupForm.Show(); + + base.OnStartup(e); + } + + protected override async void OnExit(ExitEventArgs e) + { + await AppHost!.StopAsync(); + + base.OnExit(e); + } +} diff --git a/MDIX-Testing/AssemblyInfo.cs b/MDIX-Testing/AssemblyInfo.cs new file mode 100644 index 0000000000..8b5504ecfb --- /dev/null +++ b/MDIX-Testing/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/MDIX-Testing/Dialog.xaml b/MDIX-Testing/Dialog.xaml new file mode 100644 index 0000000000..cc23b9e1b7 --- /dev/null +++ b/MDIX-Testing/Dialog.xaml @@ -0,0 +1,22 @@ + + + + + + + + +