Bodoconsult.App.Wpf 1.0.11

dotnet add package Bodoconsult.App.Wpf --version 1.0.11
                    
NuGet\Install-Package Bodoconsult.App.Wpf -Version 1.0.11
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bodoconsult.App.Wpf" Version="1.0.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bodoconsult.App.Wpf" Version="1.0.11" />
                    
Directory.Packages.props
<PackageReference Include="Bodoconsult.App.Wpf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bodoconsult.App.Wpf --version 1.0.11
                    
#r "nuget: Bodoconsult.App.Wpf, 1.0.11"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bodoconsult.App.Wpf@1.0.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bodoconsult.App.Wpf&version=1.0.11
                    
Install as a Cake Addin
#tool nuget:?package=Bodoconsult.App.Wpf&version=1.0.11
                    
Install as a Cake Tool

Bodoconsult.App.Wpf

Overview

Using app start infrastructure for a classical Wpf based apps

Using app start infrastructure for a console app employing a WPF dispatcher

Using app start infrastructure for a OS service like WPF based apps

Other tools

SharedResourceDictionary

Converters

Sending TOAST messages from WPF app

Starting WPD Dispatcher from console apps: DispatcherService class

What does the library

Bodoconsult.App.Wpf is a library with basic functionality for multilayered monolithic WPF based applications.

App start infrastructure basics

See page app start infrastructure for details.

How to use the library

The source code contains NUnit test classes the following source code is extracted from. The samples below show the most helpful use cases for the library.

Using app start infrastructure for a classical Wpf based apps

Here a sample from Program.cs Main() how to setup the Wpf app with a main form Forms1 in project AvaloniaApp1 contained in this repo:

var type = typeof(App);

Debug.Print("Hello, World!");

Console.WriteLine("AvaloniaApp1 initiation starts...");

var globals = Globals.Instance;
globals.LoggingConfig.AddDefaultLoggerProviderConfiguratorsForUiApp();

// Set additional app start parameters as required
var param = globals.AppStartParameter;
param.AppName = "AvaloniaApp1: Demo app";
param.SoftwareTeam = "Robert Leisner";
param.LogoRessourcePath = "AvaloniaApp1.Resources.logo.jpg";
param.AppFolderName = "AvaloniaApp1";

const string performanceToken = "--PERF";

if (e.Args.Contains(performanceToken))
{
    param.IsPerformanceLoggingActivated = true;
}

// Now start app buiding process
var builder = new AvaloniaApp1AppBuilder(globals);
#if !DEBUG
AppDomain.CurrentDomain.UnhandledException += builder.CurrentDomainOnUnhandledException;
#endif

// Load basic app metadata
builder.LoadBasicSettings(type);

// Process the config file
builder.ProcessConfiguration();

// Now load the globally needed settings
builder.LoadGlobalSettings();

// Prepare the DI container package
builder.LoadDiContainerServiceProviderPackage();
builder.RegisterDiServices();
builder.FinalizeDiContainerSetup();

// Create the viewmodel now
var eventLevel = EventLevel.Warning;
var listener = new AppEventListener(eventLevel);
var viewModel = new AvaloniaApp1MainWindowViewModel(listener)
{
    HeaderBackColor = Colors.DarkBlue,
    BodyBackColor = Colors.Beige,
    AppExe = param.AppExe
};

// Load the logo now
viewModel.LoadLogo(type.Assembly, param.LogoRessourcePath);

// Set the view model 
builder.MainWindowViewModel = viewModel;

// Now finally start the app and wait
builder.StartApplication();

base.OnStartup(e);

Start by creating your own viewmodel class AvaloniaApp1MainWindowViewModel derived from MainWindowViewModel and override CreateWindow() method to load your custom start window.

Using app start infrastructure for a console app employing a WPF dispatcher

If you want to use WPF features like FlowDocuments in a console app you need to employ a WPF dispatcher. In a classical WPF app starting the WPF dispatcher is done by the App.xaml start process internally. In a console app you do not have a App.xaml so the disptacher has to be started separately. Using Bodoconsult.App.Wpf you can handles this easily.

Here a sample from Program.cs Main() how to setup the console app employing a WPF dispatcher in project ConsoleAvaloniaApp1 contained in this repo:

var globals = Globals.Instance;
globals.LoggingConfig.AddDefaultLoggerProviderConfiguratorsForConsoleApp();

// Set additional app start parameters as required
var param = globals.AppStartParameter;
param.AppName = "ConsoleAvaloniaApp1: Demo app";
param.SoftwareTeam = "Robert Leisner";
param.AppFolderName = "ConsoleAvaloniaApp1";

const string performanceToken = "--PERF";

if (args.Contains(performanceToken))
{
    param.IsPerformanceLoggingActivated = true;
}

// Now start app buiding process
IAppBuilder builder = new ConsoleAvaloniaApp1AppBuilder(globals);
#if !DEBUG
    AppDomain.CurrentDomain.UnhandledException += builder.CurrentDomainOnUnhandledException;
#endif

// Load basic app metadata
builder.LoadBasicSettings(typeof(Program));

// Process the config file
builder.ProcessConfiguration();

// Now load the globally needed settings
builder.LoadGlobalSettings();

// Write first log entry with default logger
Globals.Instance.Logger.LogInformation($"{param.AppName} {param.AppVersion} starts...");
Console.WriteLine("Logging started...");

// Prepare the DI container package
builder.LoadDiContainerServiceProviderPackage();
builder.RegisterDiServices();
builder.FinalizeDiContainerSetup();

// Now finally start the app and wait
builder.StartApplication();

Environment.Exit(0);

Start by creating your own app builder class similar to ConsoleAvaloniaApp1AppBuilder class based on BaseConsoleAvaloniaAppBuilderl.

Using app start infrastructure for a OS service like WPF based apps

If you want to implement a OS service like application without implementing a real OS service you can use WpfStarterUi class.

By default WpfStarterUi class loads the app as a simple window not shown on Windows task bar but task tray. The app can be closed only with keys STRC + C / CTRL + C or from task tray.

Here a sample from App.Xaml.cs OnStartup() how to setup the WPF console app in project WpfConsoleApp1 contained in this repo:

var type = typeof(App);

Debug.Print("Hello, World!");

Console.WriteLine("WpfConsoleApp1 initiation starts...");

var globals = Globals.Instance;
globals.LoggingConfig.AddDefaultLoggerProviderConfiguratorsForUiApp();

// Set additional app start parameters as required
var param = globals.AppStartParameter;
param.AppName = "WpfConsoleApp1: Demo app";
param.SoftwareTeam = "Robert Leisner";
param.LogoRessourcePath = "WpfConsoleApp1.Resources.logo.jpg";
param.AppFolderName = "WpfConsoleApp1";

const string performanceToken = "--PERF";

if (e.Args.Contains(performanceToken))
{
    param.IsPerformanceLoggingActivated = true;
}

// Now start app buiding process
var builder = new WpfConsoleApp1AppBuilder(globals);
#if !DEBUG
AppDomain.CurrentDomain.UnhandledException += builder.CurrentDomainOnUnhandledException;
#endif

// Load basic app metadata
builder.LoadBasicSettings(type);

// Process the config file
builder.ProcessConfiguration();

// Now load the globally needed settings
builder.LoadGlobalSettings();

// Write first log entry with default logger
Globals.Instance.Logger.LogInformation($"{param.AppName} {param.AppVersion} starts...");
Console.WriteLine("Logging started...");

// Prepare the DI container package
builder.LoadDiContainerServiceProviderPackage();
builder.RegisterDiServices();
builder.FinalizeDiContainerSetup();

// Create the viewmodel now
var eventLevel = EventLevel.Warning;
var listener = new AppEventListener(eventLevel);
var viewModel = new MainWindowViewModel(listener)
{
    HeaderBackColor = Colors.Coral,
    AppExe = param.AppExe
};

// Load the logo now
viewModel.LoadLogo(type.Assembly, param.LogoRessourcePath);

// Set the view model 
builder.MainWindowViewModel = viewModel;

// Now finally start the app and wait
builder.StartApplication();

base.OnStartup(e);

Other tools

SharedResourceDictionary

Use SharedResourceDictionary class to avoid loading resources multiple times.

Use I18N providers for using Bodoocnsult.I18N with WPF resources

For basic info how to use Bodoconsult.I18N and I18N providers see Bodoconsult.I18N section.

Use WpfEmbeddedResourceProvider and WpfFileLocalesProvider to add I18N resources from WPF to Bodoocnsult.I18N.

    private const string Path = "Locales";

    [Test]
    public void RegisterLocaleItems_ExistingResources_ResourceItemsLoaded()
    {
        // Arrange 
        var ass = TestHelper.CurrentAssembly;

        var provider = new WpfEmbeddedResourceProvider(ass, Path);

        // Act  
        provider.RegisterLocaleItems();

        // Assert
        Assert.That(provider.ResourceItems, Is.Not.Null);
        Assert.That(provider.LocaleItems.Count, Is.Not.EqualTo(0));
    }

Converters

Bodoconsult.App.Wpf defines a set of converters based on IValueConverter interface:

  • ColorToBrushConverter

  • DateTimeConverter

  • DateTimeUiConverter

  • FlowDocumentContentToXamlConverter

  • FlowDocumentToXamlConverter

  • NullImageConverter

  • NumberConverter

  • PercentageConverter

Sending TOAST messages from WPF app

WpfToastMessagingService class implements sending of simple TOAST messages to the OS.

Starting WPD Dispatcher from console apps: DispatcherService class

Use the DispatcherService class to start a WPF Dispatcher in a console environment to use WPF features like Flowdocument.

About us

Bodoconsult http://www.bodoconsult.de is a Munich based software company from Germany.

Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.17763 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Bodoconsult.App.Wpf:

Package Downloads
Bodoconsult.App.Wpf.Documents

Tools to create reports based on WPF FlowDocument class

Bodoconsult.App.Wpf.ReactiveUI

New package

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.11 110 11/2/2026
1.0.10 108 11/2/2026
1.0.9 162 8/21/2026
1.0.8 176 1/11/2026
1.0.7 279 12/7/2025
1.0.6 258 7/27/2025

Enhancements, new features and bugfixes