CG.Platform.Presentation 3.10.6

dotnet add package CG.Platform.Presentation --version 3.10.6
                    
NuGet\Install-Package CG.Platform.Presentation -Version 3.10.6
                    
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="CG.Platform.Presentation" Version="3.10.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CG.Platform.Presentation" Version="3.10.6" />
                    
Directory.Packages.props
<PackageReference Include="CG.Platform.Presentation" />
                    
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 CG.Platform.Presentation --version 3.10.6
                    
#r "nuget: CG.Platform.Presentation, 3.10.6"
                    
#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 CG.Platform.Presentation@3.10.6
                    
#: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=CG.Platform.Presentation&version=3.10.6
                    
Install as a Cake Addin
#tool nuget:?package=CG.Platform.Presentation&version=3.10.6
                    
Install as a Cake Tool

Platform.Presentation

A WPF presentation library that provides base view models, custom controls, and theme management capabilities.

Features

  • Base View Models: Common MVVM patterns and base classes
  • Custom Controls: Reusable WPF controls
  • Theme Management: Dynamic MahApps.Metro theme switching
  • Culture Management: Multi-language support with culture switching
  • Settings Persistence: Application settings management with JSON storage

Getting Started

Installation

dotnet add package CG.Platform.Presentation

Basic Setup


<Application x:Class="YourApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
// Program.cs or App.xaml.cs
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Platform.Presentation.Extensions;

var services = new ServiceCollection();

// Add logging
services.AddLogging(builder =>
{
    builder.AddConsole();
    builder.AddDebug();
});

// Register platform services (includes theme, culture, and settings services)
services.RegisterPlatformServices(configuration);

var serviceProvider = services.BuildServiceProvider();

Theme Management

The library provides dynamic theme switching using MahApps.Metro themes.

Available Themes

  • Light Themes: Light.Blue, Light.Green, Light.Orange, Light.Purple, Light.Red, Light.Steel
  • Dark Themes: Dark.Blue, Dark.Green, Dark.Orange, Dark.Purple, Dark.Red, Dark.Steel

Using Theme Service

public class MainViewModel
{
    private readonly IThemeService _themeService;

    public MainViewModel(IThemeService themeService)
    {
        _themeService = themeService;
    }

    public void SwitchToDarkTheme()
    {
        _themeService.SetTheme("Dark.Blue");
    }

    public IEnumerable<string> GetAvailableThemes()
    {
        return _themeService.GetAvailableThemes();
    }
}

Theme Switching in XAML

<ComboBox ItemsSource="{Binding AvailableThemes}"
          SelectedItem="{Binding SelectedTheme}"
          SelectionChanged="OnThemeChanged" />

Culture Management

The library supports multi-language applications with culture switching.

Supported Cultures

  • English: en-US, en-GB
  • Spanish: es-ES, es-MX
  • French: fr-FR, fr-CA
  • German: de-DE, de-AT
  • Italian: it-IT
  • Portuguese: pt-BR, pt-PT
  • Russian: ru-RU
  • Asian Languages: ja-JP, ko-KR, zh-CN, zh-TW

Using Culture Service

public class MainViewModel
{
    private readonly ICultureService _cultureService;

    public MainViewModel(ICultureService cultureService)
    {
        _cultureService = cultureService;
    }

    public void SwitchToSpanish()
    {
        _cultureService.SetCulture("es-ES");
    }

    public IEnumerable<CultureInfo> GetAvailableCultures()
    {
        return _cultureService.GetAvailableCultures();
    }
}

Settings Management

The library provides persistent application settings with JSON storage.

Using Settings Service

public class MainViewModel
{
    private readonly ISettingsService _settingsService;

    public MainViewModel(ISettingsService settingsService)
    {
        _settingsService = settingsService;
        
        // Load saved settings
        var savedTheme = _settingsService.GetSetting("SelectedTheme", "Light.Blue");
        var savedLanguage = _settingsService.GetSetting("SelectedLanguage", "en-US");
    }

    public void SaveSettings()
    {
        _settingsService.SetSetting("SelectedTheme", "Dark.Blue");
        _settingsService.SetSetting("SelectedLanguage", "es-ES");
        _settingsService.SaveSettings();
    }
}

Settings Flyout

The library includes a pre-built settings flyout for theme and culture management.

Using Settings Flyout

<mah:Flyout Header="Settings" 
             Position="Right" 
             IsOpen="{Binding IsSettingsOpen}">
    <views:SettingsFlyoutView />
</mah:Flyout>
public class MainViewModel
{
    public bool IsSettingsOpen { get; set; }
    
    public void OpenSettings()
    {
        IsSettingsOpen = true;
    }
}

Service Registration

All services are automatically registered when using RegisterPlatformServices():

  • IThemeServiceThemeService
  • ICultureServiceCultureService
  • ISettingsServiceSettingsService
  • SettingsFlyoutViewModel

Configuration

Settings are automatically stored in the user's AppData folder:

  • Path: %APPDATA%\Platform.Presentation\settings.json
  • Format: JSON with automatic serialization/deserialization

Dependencies

  • MahApps.Metro: For theme support and Metro-style controls
  • CommunityToolkit.Mvvm: For MVVM patterns and commands
  • Microsoft.Extensions.Logging: For logging support
  • System.Text.Json: For settings persistence

Examples

See the SettingsFlyoutView and SettingsFlyoutViewModel for a complete example of theme and culture management in a WPF application.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.10.6 62 8/16/2025
3.10.5 60 8/16/2025
3.10.4 99 8/15/2025
3.10.3 128 8/14/2025
3.0.0 67 7/18/2025
2.9.0 133 12/10/2024
2.0.4 173 8/19/2024
2.0.3 148 8/19/2024
2.0.2 162 8/19/2024
2.0.1 174 8/18/2024
2.0.0 168 8/18/2024
1.0.2 522 7/13/2022
1.0.1 464 7/13/2022
1.0.0 468 7/13/2022