WPF Application Architecture
Purpose
WPF applications must remain maintainable as UI complexity grows. AIC uses MVVM, dependency injection and clear separation between UI and business logic.
Standard Layers
Desktop Shell
ViewModels
Application Services
Domain
InfrastructureComposition Root
The WPF app startup configures services:
public partial class App : Application
{
private IHost? _host;
protected override async void OnStartup(StartupEventArgs e)
{
_host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddApplication();
services.AddInfrastructure(context.Configuration);
services.AddSingleton<MainWindow>();
services.AddTransient<MainViewModel>();
})
.Build();
await _host.StartAsync();
var mainWindow = _host.Services.GetRequiredService<MainWindow>();
mainWindow.Show();
}
}Rules
Views define layout and interaction.
ViewModels expose state and commands.
Application services perform use cases.
Infrastructure handles persistence, files, devices and APIs.
Domain contains business rules.
UI Thread Rule
Never block the UI thread with I/O or long-running CPU work.
Use async commands and progress state.
Error Handling
WPF applications must have:
user-friendly error messages
structured logs for diagnostics
global exception handling
retry or recovery for transient failures
safe shutdown behaviour
Deployment Considerations
Document:
packaging format
installation route
update route
configuration location
logs location
user data location
rollback or uninstall approach
Was this helpful?

