Drastic.DragAndDrop.Maui
1.0.8
See the version list below for details.
dotnet add package Drastic.DragAndDrop.Maui --version 1.0.8
NuGet\Install-Package Drastic.DragAndDrop.Maui -Version 1.0.8
<PackageReference Include="Drastic.DragAndDrop.Maui" Version="1.0.8" />
paket add Drastic.DragAndDrop.Maui --version 1.0.8
#r "nuget: Drastic.DragAndDrop.Maui, 1.0.8"
// Install Drastic.DragAndDrop.Maui as a Cake Addin #addin nuget:?package=Drastic.DragAndDrop.Maui&version=1.0.8 // Install Drastic.DragAndDrop.Maui as a Cake Tool #tool nuget:?package=Drastic.DragAndDrop.Maui&version=1.0.8
Drastic.DragAndDrop.Maui
Drastic.DragAndDrop.Maui is a component for adding drag and drop views and overlay effects to a MAUI Window.
How To Use
First, you need to create the overlay and add it to a Window
instance. This can be done to an existing Window
after it has been created, or in the Window
itself with code you add.
this.overlay = new DragAndDropOverlay(this, this.overlayElement);
this.overlay.Drop += (sender, e) => this.Drop?.Invoke(this, e);
this.AddOverlay(this.overlay);
You can also use the DragAndDropWindow
to automatically add the overlay to a window. Either create your own DragAndDropWindow
after your app has launched, or replace the following in App.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
}
protected override Window CreateWindow(IActivationState? activationState)
{
return new Drastic.DragAndDrop.Maui.DragAndDropWindow(new Drastic.DragAndDrop.Maui.DragElementOverlay(Color.FromRgba(225, 0, 0, .2))) { Page = new AppShell() };
}
}
If you use DragAndDropWindow
, you can get the reference to it from the page you're on, and respond to the Drop
event.
public partial class MainPage : ContentPage
{
public MainPage()
{
this.InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
var window = (DragAndDropWindow)this.GetParentWindow();
window.Drop += Window_Drop;
}
private void Window_Drop(object? sender, DragAndDropOverlayTappedEventArgs e)
{
try
{
// Get the first path.
if (e.Paths.Any())
{
this.DropImage.Source = ImageSource.FromFile(e.Paths[0]);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
}
}
If you're using the DragAndDropOverlay
directly, you can attach to its Drop
event.
Tips
MAUI already has Drag and Drop gestures for individual elements. If you wish, you can also use Drastic.DragAndDrop
directly and subscribe to a MAUI Views PlatforView
and add a DragAndDrop control to that.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-android33.0 is compatible. net7.0-ios was computed. net7.0-ios16.0 is compatible. net7.0-maccatalyst was computed. net7.0-maccatalyst15.4 is compatible. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net7.0-windows10.0.19041 is compatible. 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. |
-
net7.0
- Drastic.DragAndDrop (>= 1.0.8)
- Drastic.Overlay (>= 1.0.8)
-
net7.0-android33.0
- Drastic.DragAndDrop (>= 1.0.8)
- Drastic.Overlay (>= 1.0.8)
-
net7.0-ios16.0
- Drastic.DragAndDrop (>= 1.0.8)
- Drastic.Overlay (>= 1.0.8)
-
net7.0-maccatalyst15.4
- Drastic.DragAndDrop (>= 1.0.8)
- Drastic.Overlay (>= 1.0.8)
-
net7.0-windows10.0.19041
- Drastic.DragAndDrop (>= 1.0.8)
- Drastic.Overlay (>= 1.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.