Skip to content

How to register a page to the Wpf.Ui.Mvvm.Contracts.IPageService service #432

Closed Answered by pomianowski
Quinton619 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Quinton619, demo applications and extension templates use the dependency injection mechanism to manage page instances. As the error indicates, IPageService does not know that the UiDesktopApp1.Views.Pages.EditorPage page has been registered.

Each Page or ViewModel is treated as a service. In the case of WPF UI templates, pages are registered in App.xaml.cs.

public partial class App
{
    private static readonly IHost _host = Host
        .CreateDefaultBuilder()
        .ConfigureServices((context, services) =>
        {
            // Register EditorPage class as service, which is instantiated only once
            services.AddSingleton<UiDesktopApp1.Views.Pages.EditorPage>();
        }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TimexPeachtree
Comment options

Answer selected by pomianowski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants