using Wpf.Ui; namespace Seyounth.Hyosung.UI.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; } } }