Mvvm.CommonInteractions.Avalonia 1.0.58

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mvvm.CommonInteractions.Avalonia --version 1.0.58                
NuGet\Install-Package Mvvm.CommonInteractions.Avalonia -Version 1.0.58                
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="Mvvm.CommonInteractions.Avalonia" Version="1.0.58" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mvvm.CommonInteractions.Avalonia --version 1.0.58                
#r "nuget: Mvvm.CommonInteractions.Avalonia, 1.0.58"                
#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.
// Install Mvvm.CommonInteractions.Avalonia as a Cake Addin
#addin nuget:?package=Mvvm.CommonInteractions.Avalonia&version=1.0.58

// Install Mvvm.CommonInteractions.Avalonia as a Cake Tool
#tool nuget:?package=Mvvm.CommonInteractions.Avalonia&version=1.0.58                

Mvvm.CommonInteractions

Common MVVM Level Interactions(like open/save file) for WPF/UWP/WinUI/Uno/Avalonia platforms. Features:

  • Enables drag-and-drop support at the ViewModel level.
  • Wide choice of platforms
  • Dependency injection friendly

NuGet

NuGet NuGet NuGet NuGet NuGet NuGet

Install-Package Mvvm.CommonInteractions.Core
Install-Package Mvvm.CommonInteractions.Wpf
Install-Package Mvvm.CommonInteractions.Uno
Install-Package Mvvm.CommonInteractions.Uwp
Install-Package Mvvm.CommonInteractions.WinUI
Install-Package Mvvm.CommonInteractions.Avalonia

Usage

Add to your App constructors:


public sealed partial class App
{
    private IHost AppHost { get; }

    public App()
    {
        AppHost = Host
            .CreateDefaultBuilder()
            .ConfigureServices(static services =>
            {
                services.AddSingleton<IFileInteractions, FileInteractions>();
                services.AddSingleton<IMessageInteractions, MessageInteractions>();
                services.AddSingleton<IWebInteractions, WebInteractions>();
            })
            .Build();

        // Optional. Displays unhandled exceptions using MessageInteractions.Exception.
        AppHost.Services.GetRequiredService<IMessageInteractions>().CatchUnhandledExceptions(this);

        // your code
    }
}

FileInteractions

// Open
var file = await FileInteractions.OpenFileAsync(new OpenFileArguments
{
    SuggestedFileName = "my.txt",
    Extensions = new[] { ".txt" },
    FilterName = "My txt files",
});
if (file == null)
{
    return;
}
var text = await file.ReadTextAsync().ConfigureAwait(true);

// Save (you need to save file from previuos step)
await file.WriteTextAsync(text).ConfigureAwait(false);

// Save As
var file = await FileInteractions.SaveFileAsync(new SaveFileArguments(".txt")
{
    SuggestedFileName = "my.txt",
    FilterName = "My txt files",
});
if (file == null)
{
    return;
}
await file.WriteTextAsync(text).ConfigureAwait(false);

MessageInteractions

await MessageInteractions.ShowMessageAsync("Message");
await MessageInteractions.ShowWarningAsync("Warning");
await MessageInteractions.ShowExceptionAsync(new InvalidOperationException("Exception"));
bool question = await MessageInteractions.ShowQuestionAsync(new QuestionData("Are you sure?"));

WinUI requires a window to display the ContentDialog, so you'll need to set it explicitly in your App.OnLaunched:

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
#if HAS_WINUI
    var window = new Window();
    MessageInteractions.Window = window;
#endif
}

WebInteractions

await WebInteractions.OpenUrlAsync("https://www.google.com/");

DragAndDropExtensions

// WPF
xmlns:dragAndDrop="clr-namespace:Mvvm.CommonInteractions;assembly=Mvvm.CommonInteractions.Wpf" 
// UWP/Uno
xmlns:dragAndDrop="using:Mvvm.CommonInteractions"
<Element
    AllowDrop="True"
    dragAndDrop:DragAndDropExtensions.DragFilesEnterCommand="{Binding DragFilesEnter}"
    dragAndDrop:DragAndDropExtensions.DragTextEnterCommand="{Binding DragTextEnter}"
    dragAndDrop:DragAndDropExtensions.DragLeaveCommand="{Binding DragLeave}"
    dragAndDrop:DragAndDropExtensions.DropFilesCommand="{Binding DropFiles}"
    dragAndDrop:DragAndDropExtensions.DropTextCommand="{Binding DropText}"
    >

Command arguments: DragFilesEnterCommand - FileData[] - Array of files.
DragTextEnterCommand - string - Text.
DragLeaveCommand - null.
DropFilesCommand - FileData[] - Array of files.
DropTextCommand - string - Text.

Contacts

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.68 324 12/18/2023
1.0.65 365 2/27/2023
1.0.64 391 1/6/2023
1.0.63 354 1/6/2023
1.0.59 374 1/6/2023
1.0.58 490 8/22/2022
1.0.57 466 8/22/2022

⭐ Last 10 features:
- feat: Removed ReactiveUI dependency. 2022-08-22
- feat: To IsExternalInit package. 2022-08-22
- feat: Updated NuGet packages. 2022-08-11
- feat: Updated NuGet packages. 2022-07-11
- feat: Published WebAssembly app. 2022-07-01
- feat: Updated NuGet packages. 2022-07-01
- feat: To DependencyPropertyGenerator. 2022-06-29
- feat: Updated NuGet packages. 2022-06-29
- feat: Added BaseConverter DefaultConvertValue/DefaultConvertBackValue. 2022-06-24
- feat: Updated NuGet packages. 2022-03-25

🐞 Last 10 bug fixes:
- fix: Fixed GetRequiredWindow exception message. 2022-08-22
- fix: To WinRT.Interop. 2022-07-14
- fix: Disabled linker. 2022-07-01
- fix: Fixed Uno targets. 2022-03-18
- fix: Fixed missing Warning ContentDialog. 2022-03-17
- fix(apps): Fixed Uno.WinUI webassembly app. 2022-01-19
- fix: Fixed package description. 2021-12-22
- fix(Avalonia): Changed BaseConverter null values to UnsetValue. 2021-12-15
- fix(Avalonia): Fixed OpenFileDialog Filters bug. 2021-12-11
- fix: Fixed CI to release avalonia. 2021-12-10