diff --git a/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs index 2f88101a2..c61e08387 100644 --- a/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Blank/App.xaml.cs @@ -27,22 +27,19 @@ public partial class App }).Build(); /// - /// Gets registered service. + /// Gets services. /// - /// Type of the service to get. - /// Instance of the service or . - public static T GetService() - where T : class + public static IServiceProvider Services { - return _host.Services.GetService(typeof(T)) as T; + get { return _host.Services; } } /// /// Occurs when the application is loading. /// - private void OnStartup(object sender, StartupEventArgs e) + private async void OnStartup(object sender, StartupEventArgs e) { - _host.Start(); + await _host.StartAsync(); } /// diff --git a/src/Wpf.Ui.Extension.Template.Blank/Wpf.Ui.Blank.csproj b/src/Wpf.Ui.Extension.Template.Blank/Wpf.Ui.Blank.csproj index f43c38506..843153ed8 100644 --- a/src/Wpf.Ui.Extension.Template.Blank/Wpf.Ui.Blank.csproj +++ b/src/Wpf.Ui.Extension.Template.Blank/Wpf.Ui.Blank.csproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows + net9.0-windows app.manifest wpfui-icon.ico true @@ -15,9 +15,9 @@ - - - + + + diff --git a/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs index 5e3346fdd..551f4e925 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/App.xaml.cs @@ -10,6 +10,7 @@ using $safeprojectname$.Views.Pages; using $safeprojectname$.Views.Windows; using Wpf.Ui; +using Wpf.Ui.DependencyInjection; namespace $safeprojectname$ { @@ -28,10 +29,9 @@ public partial class App .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); }) .ConfigureServices((context, services) => { - services.AddHostedService(); + services.AddNavigationViewPageProvider(); - // Page resolver service - services.AddSingleton(); + services.AddHostedService(); // Theme manipulation services.AddSingleton(); @@ -55,22 +55,19 @@ public partial class App }).Build(); /// - /// Gets registered service. + /// Gets services. /// - /// Type of the service to get. - /// Instance of the service or . - public static T GetService() - where T : class + public static IServiceProvider Services { - return _host.Services.GetService(typeof(T)) as T; + get { return _host.Services; } } /// /// Occurs when the application is loading. /// - private void OnStartup(object sender, StartupEventArgs e) + private async void OnStartup(object sender, StartupEventArgs e) { - _host.Start(); + await _host.StartAsync(); } /// diff --git a/src/Wpf.Ui.Extension.Template.Compact/Services/PageService.cs b/src/Wpf.Ui.Extension.Template.Compact/Services/PageService.cs deleted file mode 100644 index 2578f166d..000000000 --- a/src/Wpf.Ui.Extension.Template.Compact/Services/PageService.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Wpf.Ui; - -namespace $safeprojectname$.Services -{ - /// - /// Service that provides pages for navigation. - /// - public class PageService : IPageService - { - /// - /// Service which provides the instances of pages. - /// - private readonly IServiceProvider _serviceProvider; - - /// - /// Creates new instance and attaches the . - /// - public PageService(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - - /// - public T? GetPage() - where T : class - { - if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T))) - throw new InvalidOperationException("The page should be a WPF control."); - - return (T?)_serviceProvider.GetService(typeof(T)); - } - - /// - public FrameworkElement? GetPage(Type pageType) - { - if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) - throw new InvalidOperationException("The page should be a WPF control."); - - return _serviceProvider.GetService(pageType) as FrameworkElement; - } - } -} diff --git a/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/DataViewModel.cs b/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/DataViewModel.cs index 449dcf9c7..fc5225155 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/DataViewModel.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/DataViewModel.cs @@ -1,6 +1,6 @@ using System.Windows.Media; using $safeprojectname$.Models; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.ViewModels.Pages { @@ -11,13 +11,15 @@ public partial class DataViewModel : ObservableObject, INavigationAware [ObservableProperty] private IEnumerable _colors; - public void OnNavigatedTo() + public Task OnNavigatedToAsync() { if (!_isInitialized) InitializeViewModel(); + + return Task.CompletedTask; } - public void OnNavigatedFrom() { } + public Task OnNavigatedFromAsync() => Task.CompletedTask; private void InitializeViewModel() { diff --git a/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/SettingsViewModel.cs index 2d0224df3..1a743f36e 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/SettingsViewModel.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/ViewModels/Pages/SettingsViewModel.cs @@ -1,5 +1,5 @@ using Wpf.Ui.Appearance; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.ViewModels.Pages { @@ -13,13 +13,15 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware [ObservableProperty] private ApplicationTheme _currentTheme = ApplicationTheme.Unknown; - public void OnNavigatedTo() + public Task OnNavigatedToAsync() { if (!_isInitialized) InitializeViewModel(); + + return Task.CompletedTask; } - public void OnNavigatedFrom() { } + public Task OnNavigatedFromAsync() => Task.CompletedTask; private void InitializeViewModel() { diff --git a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DashboardPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DashboardPage.xaml.cs index 288b6feeb..97a97382d 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DashboardPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DashboardPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DataPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DataPage.xaml.cs index 5c0fa3e89..566af09d4 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DataPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/DataPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/SettingsPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/SettingsPage.xaml.cs index c3decb5af..ee4559d8f 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/SettingsPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/Views/Pages/SettingsPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Compact/Views/Windows/MainWindow.xaml.cs b/src/Wpf.Ui.Extension.Template.Compact/Views/Windows/MainWindow.xaml.cs index 5e09543d8..8c138073b 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Views/Windows/MainWindow.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Compact/Views/Windows/MainWindow.xaml.cs @@ -1,5 +1,6 @@ using $safeprojectname$.ViewModels.Windows; using Wpf.Ui; +using Wpf.Ui.Abstractions; using Wpf.Ui.Appearance; using Wpf.Ui.Controls; @@ -11,7 +12,7 @@ public partial class MainWindow : INavigationWindow public MainWindow( MainWindowViewModel viewModel, - IPageService pageService, + INavigationViewPageProvider navigationViewPageProvider, INavigationService navigationService ) { @@ -21,7 +22,7 @@ INavigationService navigationService SystemThemeWatcher.Watch(this); InitializeComponent(); - SetPageService(pageService); + SetPageService(navigationViewPageProvider); navigationService.SetNavigationControl(RootNavigation); } @@ -32,7 +33,7 @@ INavigationService navigationService public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType); - public void SetPageService(IPageService pageService) => RootNavigation.SetPageService(pageService); + public void SetPageService(INavigationViewPageProvider navigationViewPageProvider) => RootNavigation.SetPageProviderService(navigationViewPageProvider); public void ShowWindow() => Show(); diff --git a/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.csproj b/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.csproj index f43c38506..a5785e118 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.csproj +++ b/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.csproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows + net9.0-windows app.manifest wpfui-icon.ico true @@ -15,9 +15,10 @@ - - - + + + + diff --git a/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.vstemplate b/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.vstemplate index 3ccb210be..375ae28d9 100644 --- a/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.vstemplate +++ b/src/Wpf.Ui.Extension.Template.Compact/Wpf.Ui.Compact.vstemplate @@ -39,7 +39,6 @@ ApplicationHostService.cs - PageService.cs diff --git a/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs index 5e3346fdd..551f4e925 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/App.xaml.cs @@ -10,6 +10,7 @@ using $safeprojectname$.Views.Pages; using $safeprojectname$.Views.Windows; using Wpf.Ui; +using Wpf.Ui.DependencyInjection; namespace $safeprojectname$ { @@ -28,10 +29,9 @@ public partial class App .ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); }) .ConfigureServices((context, services) => { - services.AddHostedService(); + services.AddNavigationViewPageProvider(); - // Page resolver service - services.AddSingleton(); + services.AddHostedService(); // Theme manipulation services.AddSingleton(); @@ -55,22 +55,19 @@ public partial class App }).Build(); /// - /// Gets registered service. + /// Gets services. /// - /// Type of the service to get. - /// Instance of the service or . - public static T GetService() - where T : class + public static IServiceProvider Services { - return _host.Services.GetService(typeof(T)) as T; + get { return _host.Services; } } /// /// Occurs when the application is loading. /// - private void OnStartup(object sender, StartupEventArgs e) + private async void OnStartup(object sender, StartupEventArgs e) { - _host.Start(); + await _host.StartAsync(); } /// diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Services/PageService.cs b/src/Wpf.Ui.Extension.Template.Fluent/Services/PageService.cs deleted file mode 100644 index 2578f166d..000000000 --- a/src/Wpf.Ui.Extension.Template.Fluent/Services/PageService.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Wpf.Ui; - -namespace $safeprojectname$.Services -{ - /// - /// Service that provides pages for navigation. - /// - public class PageService : IPageService - { - /// - /// Service which provides the instances of pages. - /// - private readonly IServiceProvider _serviceProvider; - - /// - /// Creates new instance and attaches the . - /// - public PageService(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - - /// - public T? GetPage() - where T : class - { - if (!typeof(FrameworkElement).IsAssignableFrom(typeof(T))) - throw new InvalidOperationException("The page should be a WPF control."); - - return (T?)_serviceProvider.GetService(typeof(T)); - } - - /// - public FrameworkElement? GetPage(Type pageType) - { - if (!typeof(FrameworkElement).IsAssignableFrom(pageType)) - throw new InvalidOperationException("The page should be a WPF control."); - - return _serviceProvider.GetService(pageType) as FrameworkElement; - } - } -} diff --git a/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/DataViewModel.cs b/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/DataViewModel.cs index 449dcf9c7..fc5225155 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/DataViewModel.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/DataViewModel.cs @@ -1,6 +1,6 @@ using System.Windows.Media; using $safeprojectname$.Models; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.ViewModels.Pages { @@ -11,13 +11,15 @@ public partial class DataViewModel : ObservableObject, INavigationAware [ObservableProperty] private IEnumerable _colors; - public void OnNavigatedTo() + public Task OnNavigatedToAsync() { if (!_isInitialized) InitializeViewModel(); + + return Task.CompletedTask; } - public void OnNavigatedFrom() { } + public Task OnNavigatedFromAsync() => Task.CompletedTask; private void InitializeViewModel() { diff --git a/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/SettingsViewModel.cs b/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/SettingsViewModel.cs index 2d0224df3..1a743f36e 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/SettingsViewModel.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/ViewModels/Pages/SettingsViewModel.cs @@ -1,5 +1,5 @@ using Wpf.Ui.Appearance; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.ViewModels.Pages { @@ -13,13 +13,15 @@ public partial class SettingsViewModel : ObservableObject, INavigationAware [ObservableProperty] private ApplicationTheme _currentTheme = ApplicationTheme.Unknown; - public void OnNavigatedTo() + public Task OnNavigatedToAsync() { if (!_isInitialized) InitializeViewModel(); + + return Task.CompletedTask; } - public void OnNavigatedFrom() { } + public Task OnNavigatedFromAsync() => Task.CompletedTask; private void InitializeViewModel() { diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DashboardPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DashboardPage.xaml.cs index 288b6feeb..97a97382d 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DashboardPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DashboardPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DataPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DataPage.xaml.cs index 5c0fa3e89..566af09d4 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DataPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/DataPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/SettingsPage.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/SettingsPage.xaml.cs index c3decb5af..ee4559d8f 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/SettingsPage.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/Views/Pages/SettingsPage.xaml.cs @@ -1,5 +1,5 @@ using $safeprojectname$.ViewModels.Pages; -using Wpf.Ui.Controls; +using Wpf.Ui.Abstractions.Controls; namespace $safeprojectname$.Views.Pages { diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Views/Windows/MainWindow.xaml.cs b/src/Wpf.Ui.Extension.Template.Fluent/Views/Windows/MainWindow.xaml.cs index 5e09543d8..8c138073b 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Views/Windows/MainWindow.xaml.cs +++ b/src/Wpf.Ui.Extension.Template.Fluent/Views/Windows/MainWindow.xaml.cs @@ -1,5 +1,6 @@ using $safeprojectname$.ViewModels.Windows; using Wpf.Ui; +using Wpf.Ui.Abstractions; using Wpf.Ui.Appearance; using Wpf.Ui.Controls; @@ -11,7 +12,7 @@ public partial class MainWindow : INavigationWindow public MainWindow( MainWindowViewModel viewModel, - IPageService pageService, + INavigationViewPageProvider navigationViewPageProvider, INavigationService navigationService ) { @@ -21,7 +22,7 @@ INavigationService navigationService SystemThemeWatcher.Watch(this); InitializeComponent(); - SetPageService(pageService); + SetPageService(navigationViewPageProvider); navigationService.SetNavigationControl(RootNavigation); } @@ -32,7 +33,7 @@ INavigationService navigationService public bool Navigate(Type pageType) => RootNavigation.Navigate(pageType); - public void SetPageService(IPageService pageService) => RootNavigation.SetPageService(pageService); + public void SetPageService(INavigationViewPageProvider navigationViewPageProvider) => RootNavigation.SetPageProviderService(navigationViewPageProvider); public void ShowWindow() => Show(); diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.csproj b/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.csproj index 6175bde79..a5785e118 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.csproj +++ b/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.csproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows + net9.0-windows app.manifest wpfui-icon.ico true @@ -15,9 +15,10 @@ - - - + + + + diff --git a/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.vstemplate b/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.vstemplate index 6207098f9..ef4274f83 100644 --- a/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.vstemplate +++ b/src/Wpf.Ui.Extension.Template.Fluent/Wpf.Ui.Fluent.vstemplate @@ -39,7 +39,6 @@ ApplicationHostService.cs - PageService.cs diff --git a/src/Wpf.Ui.Extension/source.extension.vsixmanifest b/src/Wpf.Ui.Extension/source.extension.vsixmanifest index 88e080ca7..49efd1eb7 100644 --- a/src/Wpf.Ui.Extension/source.extension.vsixmanifest +++ b/src/Wpf.Ui.Extension/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + WPF UI WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly. https://github.com/lepoco/wpfui