Table of Contents

Class WpfApplication

Namespace
Tudormobile.Wpf
Assembly
Tudormobile.WpfApp.dll

Provides an enhanced implementation to encapsule a Windows Presentation Foundation (WPF) Application.

This implementation of the Application class adds a single additional override method, OnConfigureServices(IServiceCollection), that alows you to configure the dependency injection container for the application.

public class WpfApplication : Application, IQueryAmbient
Inheritance
WpfApplication
Implements
Inherited Members

Constructors

WpfApplication()

Creates a new instance of the WpfApplication class and initializes the service collection. The constructor also calls the OnConfigureServices(IServiceCollection) virtual method that the application can override to configure services.

public WpfApplication()

Properties

CommandLine

Provides access to the command line arguments passed to the application.

public CommandLine CommandLine { get; }

Property Value

CommandLine

Current

Gets the current application instance for the application domain, overrideing the base class implementation.

public static WpfApplication Current { get; }

Property Value

WpfApplication

Remarks

This property provides access to the singleton instance of the WpfApplication class for the current application domain. Use this property to interact with application-wide resources or state, such as managing global events or accessing shared data.

ServiceProvider

Gets the current service provider for resolving application services.

public static IServiceProvider ServiceProvider { get; }

Property Value

IServiceProvider

Remarks

Use this property to retrieve services registered in the application's dependency injection container. This property is a convenient way to access the service provider without needing to run through the Current.

Services

Gets the service provider that resolves service dependencies.

public IServiceProvider Services { get; }

Property Value

IServiceProvider

Remarks

The service provider is built from the underlying service collection. Accessing this property will initialize the service provider if it has not already been created.

Methods

OnConfigureServices(IServiceCollection)

Allows derived classes to configure additional services for the application.

protected virtual void OnConfigureServices(IServiceCollection services)

Parameters

services IServiceCollection

The IServiceCollection to which services can be added.

Remarks

This method is intended to be overridden in derived classes to register custom services or modify existing service configurations. It is called during the application's service configuration phase.

OnMainWindowCreated()

Allows derived classes to be notified when the MainWindow is activated for the first time.

protected virtual void OnMainWindowCreated()

Remarks

This method is intended to be overridden in derived classes to allow for custom logic to be executed when the main window of the application is created and activated for the first time.