diff --git a/MvvmCommunityApp/App.xaml.cs b/MvvmCommunityApp/App.xaml.cs index b8d8e43..7c04f32 100644 --- a/MvvmCommunityApp/App.xaml.cs +++ b/MvvmCommunityApp/App.xaml.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using MvvmCommunityApp.interfaces; using MvvmCommunityApp.services; using MvvmCommunityApp.viewmodels; +using System; using System.Windows; namespace MvvmCommunityApp @@ -12,17 +13,35 @@ namespace MvvmCommunityApp /// public partial class App : Application { - protected override void OnStartup(StartupEventArgs e) + public new static App Current => (App)Application.Current; + + public App() { - base.OnStartup(e); + // !!! Add constructor initialization HERE !!!! + // configure mvvm ioc + ConfigureServices(); + } + private void ConfigureServices() => // setup mvvm ioc Ioc.Default.ConfigureServices( new ServiceCollection() .AddTransient() .AddSingleton() + .AddSingleton() .BuildServiceProvider()); + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + // setup mvvm ioc + //Ioc.Default.ConfigureServices( + // new ServiceCollection() + // .AddTransient() + // .AddSingleton() + // .BuildServiceProvider()); + // load the main / entry page MainWindow wnd = new MainWindow(); diff --git a/MvvmCommunityApp/MainWindow.xaml b/MvvmCommunityApp/MainWindow.xaml index 5943db7..e468cda 100644 --- a/MvvmCommunityApp/MainWindow.xaml +++ b/MvvmCommunityApp/MainWindow.xaml @@ -8,7 +8,9 @@ Title="MainWindow" Height="450" Width="800"> - + +