CommunityInteractions.Avalonia 2.0.0

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

CommunityInteractions.Avalonia

Simple package providing a streamlined way for showing dialog boxes, inspired by ReactiveUI.

Introductions

CommunityInteractions.Avalonia is a library simplifying the process of creating new windows and dialog boxes. Inspired by ReactiveUI allows for easy window creation. Compatible with any MVVM framework.

Usage

In your ViewModel create a public readonly property of type Interaction. This will be the bridge between your ViewModel and Window.

public partial class MainWindowViewModel : ViewModelBase
{
	public readonly Interaction OpenDialogInteraction = new(new DialogWindow());
}

You can also set the window later when you need it.

public partial class MainWindowViewModel : ViewModelBase
{
    public readonly Interaction OpenDialogInteraction = new();
    
    [RelayCommand]
    private async Task OpenDialog()
    {
        OpenDialogInteraction.Window = new DialogWindow();
    }
}

Next, register the owner-window from the Window class.

public partial class MainWindow : Window
{
	private readonly MainWindowViewModel _vm = new();
	public MainWindow()
	{
		InitializeComponent();
		DataContext = _vm;
		
		_vm.OpenDialogInteraction.Register(this);
	}
}

Now, if you want to show your window, just call the Show()/ShowDialog() method. You can also retrieve the return data of a dialog by specifying its type.

// Opens window
OpenDialogInteraction.Show();

// Opens dialog
await OpenDialogInteraction.ShowDialog();

// Opens dialog and retrieves information provided by the Close method of a dialog window (Close(data))
string res = await OpenDialogInteraction.ShowDialog<string>();

Examples

Examples are provided in the CommunityInteractions.Dev project.

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 is compatible.  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
2.0.0 251 4/13/2025
1.0.0 165 4/10/2025