Consolonia.Modal 12.0.3.62

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

Consolonia.Modal

Consolonia.Modal provides a mechanism for displaying modal dialogs in Consolonia applications.

Features

  • Modal Overlay: Shades the background to prevent interaction with the main window.
  • Integration: Use ModalTheme to enable modal support for all windows.
  • Customization: Control the title, icon, close button visibility, and keyboard behavior (Escape key).
  • Layout: Modal size and position are determined by the ModalWindow properties and its first child.

Installation

Add the Consolonia.Modal package to your project and include the ModalTheme in your App.axaml:

<Application ...
             xmlns:console="https://github.com/consolonia"
             xmlns:modal="clr-namespace:Consolonia.Modal;assembly=Consolonia.Modal">
    <Application.Styles>
        <console:ModernTheme /> 
        <modal:ModalTheme />
    </Application.Styles>
</Application>

The ModalTheme attaches a ModalHost to every Window, which is required for displaying modal dialogs.

Usage

1. Create a Modal Window

Create a new XAML file for your modal, inheriting from modal:ModalWindow. Set alignment on the ModalWindow itself to control its position.

<modal:ModalWindow xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:modal="clr-namespace:Consolonia.Modal;assembly=Consolonia.Modal"
                    x:Class="MyApp.MyModal"
                    Title="Confirmation"
                    Icon="❓"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center">
    
    <StackPanel Spacing="1">
        <TextBlock Text="Are you sure you want to proceed?" />
        <StackPanel Orientation="Horizontal" Spacing="2" HorizontalAlignment="Center">
            <Button Content="OK" Click="OnOkClick" />
            <Button Content="Cancel" Click="OnCancelClick" />
        </StackPanel>
    </StackPanel>
</modal:ModalWindow>

2. Show the Modal

Call ShowModalAsync from your code-behind:

var modal = new MyModal();
await modal.ShowModalAsync(this); // 'this' is the parent window or control

Layout and Alignment

A ModalWindow spans the entire parent window by default to provide the modal overlay. The actual "modal box" (the frame with the title and borders) follows the size of the first child and is centered within the ModalWindow.

The Role of the First Child

The size of the modal frame depends on the first child of the ModalWindow.

  • Sizing: The modal frame automatically calculates its size based on the dimensions of the first child.
  • Alignment: The first child must have its HorizontalAlignment and VerticalAlignment set to Stretch (the default). Setting them to Center or other values will cause layout issues.
  • Margins: Avoid setting a Margin on the first child, as it will behave like padding inside the modal frame.

Positioning the Modal

To control the position, size, or margins of the modal box relative to the screen, set these properties on the ModalWindow itself:

  • Centering: Set HorizontalAlignment="Center" and VerticalAlignment="Center" on the ModalWindow.
  • Margins: Set Margin on the ModalWindow to add space between the overlay edges and the modal.
  • Docking: Use Left, Right, Top, or Bottom alignments on the ModalWindow.

Properties

Property Type Description
Title string The text displayed in the modal header.
Icon object An icon displayed next to the title.
IsCloseButtonVisible bool Whether to show the [x] close button (Default: true).
CancelOnEscape bool Whether the modal can be closed by pressing the Escape key (Default: true).
Margin Thickness Should be used on the ModalWindow itself to limit the modal area.

Customizing Themes

Consolonia.Modal supports both Modern and TurboVision themes. The ModalTheme automatically picks the appropriate styles based on the active Consolonia theme.

If you need to customize the look of all modals, you can override the ControlTheme for modal:ModalWindow or modal:ModalWindowHeader.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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
12.0.3.62 114 8/27/2026
12.0.3.58-alpha.58 53 8/25/2026
12.0.3.57-alpha.57 64 8/25/2026
12.0.3.56-alpha.56 63 8/25/2026
12.0.3.47 166 8/10/2026
11.3.12.5 344 4/16/2026