Class MudDropContainer<T>
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
A container of MudDropZone<T> components for drag-and-drop operations.
public class MudDropContainer<T> : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged where T : notnull
Type Parameters
T
The type of item dragged and dropped within this container.
- Inheritance
-
MudDropContainer<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
MudDropContainer()
public MudDropContainer()
Properties
ApplyDropClassesOnDragStarted
Applies either CanDropClass or NoDropClass to drop zones during a drag-and-drop transaction.
[Parameter]
[Category("DropRules")]
public bool ApplyDropClassesOnDragStarted { get; set; }
Property Value
Remarks
Defaults to false
. The CanDrop function determines which classes are applied.
CanDrop
The function which determines whether an item can be dropped within a drop zone.
[Parameter]
[Category("DropRules")]
public Func<T, string, bool>? CanDrop { get; set; }
Property Value
Remarks
When a drop zone is allowed, the CanDropClass is applied, otherwise NoDropClass is applied.
CanDropClass
The CSS classes applied to valid drop zones.
[Parameter]
[Category("DropRules")]
public string? CanDropClass { get; set; }
Property Value
Remarks
This class is applied when CanDrop returns true
for an item. Multiple classes must be separated by spaces.
ChildContent
The content within this container.
[Parameter]
[Category("Appearance")]
public RenderFragment? ChildContent { get; set; }
Property Value
Remarks
The content should include at least two MudDropZone<T> components.
Classname
protected string Classname { get; }
Property Value
DisabledClass
The CSS classes applied to disabled drop items.
[Parameter]
[Category("Disable")]
public string DisabledClass { get; set; }
Property Value
Remarks
This class is applied when ItemDisabled returns true
for an item. Multiple classes must be separated by spaces.
DraggingClass
The CSS classes applied to drop zones during a drag-and-drop operation.
[Parameter]
[Category("DraggingClass")]
public string? DraggingClass { get; set; }
Property Value
Remarks
Multiple classes must be separated by spaces.
ItemDisabled
The function which determines whether an item cannot be dragged.
[Parameter]
[Category("Disable")]
public Func<T, bool>? ItemDisabled { get; set; }
Property Value
Remarks
If no value is given, all items can be dragged by default. When an item is disabled, the DisabledClass is applied.
ItemDraggingClass
The CSS classes applied to items during a drag-and-drop operation.
[Parameter]
[Category("DraggingClass")]
public string? ItemDraggingClass { get; set; }
Property Value
Remarks
Multiple classes must be separated by spaces.
ItemDropped
Occurs when an item has been dropped into a MudDropZone<T>.
[Parameter]
[Category("Items")]
public EventCallback<MudItemDropInfo<T>> ItemDropped { get; set; }
Property Value
ItemPicked
Occurs when an item starts being dragged.
[Parameter]
[Category("Items")]
public EventCallback<MudDragAndDropItemTransaction<T>> ItemPicked { get; set; }
Property Value
Remarks
A new MudDragAndDropItemTransaction<T> is started which tracks the drag-and-drop operation until it is completed or canceled.
ItemRenderer
The template used to render items within a drop zone.
[Parameter]
[Category("Items")]
public RenderFragment<T>? ItemRenderer { get; set; }
Property Value
Items
The items that can be dragged and dropped within this container.
[Parameter]
[Category("Items")]
public IEnumerable<T> Items { get; set; }
Property Value
- IEnumerable<T>
ItemsClassSelector
The function which determines the CSS classes for each item.
[Parameter]
[Category("Items")]
public Func<T, string, string>? ItemsClassSelector { get; set; }
Property Value
ItemsSelector
The function which determines whether an item can be dropped within a drop zone.
[Parameter]
[Category("Items")]
public Func<T, string, bool>? ItemsSelector { get; set; }
Property Value
NoDropClass
The CSS classes applied to invalid drop zones.
[Parameter]
[Category("DropRules")]
public string? NoDropClass { get; set; }
Property Value
Remarks
This class is applied when CanDrop returns false
for an item. Multiple classes must be separated by spaces.
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
CancelTransaction()
Cancels a drag-and-drop transaction.
public Task CancelTransaction()
Returns
CommitTransaction(string, bool)
Completes a drag-and-drop transaction.
public Task CommitTransaction(string dropZoneIdentifier, bool reorderIsAllowed)
Parameters
dropZoneIdentifier
stringThe unique ID of the zone the item was dropped onto.
reorderIsAllowed
boolWhen
true
, items can be reordered.
Returns
GetTransactionCurrentZoneIdentifier()
Gets the unique ID of the zone where the item is currently hovering.
public string GetTransactionCurrentZoneIdentifier()
Returns
- string
The unique ID of the zone.
GetTransactionIndex()
Gets the index of the zone the item is currently hovering over.
public int GetTransactionIndex()
Returns
- int
The index of the zone.
GetTransactionItem()
Gets the item currently being dragged.
public T? GetTransactionItem()
Returns
- T
The item being dragged, or
null
of no drag is in progress.
GetTransactionOriginZoneIdentifier()
Gets the unique ID of the zone where the drag-and-drop started.
public string GetTransactionOriginZoneIdentifier()
Returns
- string
The unique ID of the zone.
HasTransactionIndexChanged()
Gets whether the item is located over a different zone than the original zone.
public bool HasTransactionIndexChanged()
Returns
- bool
When
true
, the item has moved from the original zone.
IsItemMovedDownwards()
Gets whether the current index of the zone is greater than the zone where the transaction started.
public bool IsItemMovedDownwards()
Returns
- bool
When
true
, the item's current zone index is higher than the original zone.
IsOrigin(int, string)
Gets whether the specified zone is where the drag-and-drop transaction started.
public bool IsOrigin(int index, string identifier)
Parameters
Returns
- bool
When
true
, the zone is where the drag-and-drop transaction started.
IsTransactionOriginatedFromInside(string)
Gets whether the item being dragged originated from the specified zone.
public bool IsTransactionOriginatedFromInside(string identifier)
Parameters
identifier
stringThe unique ID of the zone to find.
Returns
- bool
when
true
, the item was dragged from the specified zone.
Refresh()
Refreshes the drop zone and all items within.
public void Refresh()
Remarks
When called, the RefreshRequested event is raised. This is typically used when adding items to the collection or changing values of items.
StartTransaction(T?, string, int, Func<Task>, Func<Task>)
Starts a new drag-and-drop operation.
public void StartTransaction(T? item, string identifier, int index, Func<Task> commitCallback, Func<Task> cancelCallback)
Parameters
item
TThe item to drag.
identifier
stringThe unique identifier for the item.
index
intThe index of the zone where the drag started.
commitCallback
Func<Task>Occurs when the drag-and-drop has finished successfully.
cancelCallback
Func<Task>Occurs when the drag-and-drop operation has been canceled.
TransactionInProgress()
Gets whether a drag-and-drop is in progress.
public bool TransactionInProgress()
Returns
UpdateTransactionIndex(int)
Updates the index of the zone the item is being dragged over.
public void UpdateTransactionIndex(int index)
Parameters
index
intThe index of the current zone.
Events
RefreshRequested
Occurs when a refresh for this component has been requested.
public event EventHandler? RefreshRequested
Event Type
TransactionEnded
Occurs when a drag-and-drop operation has completed or canceled.
public event EventHandler<MudDragAndDropTransactionFinishedEventArgs<T>>? TransactionEnded
Event Type
TransactionIndexChanged
Occurs when an ongoing drop-and-drop has changed destinations.
public event EventHandler<MudDragAndDropIndexChangedEventArgs>? TransactionIndexChanged
Event Type
TransactionStarted
Occurs when a new drag-and-drop operation has started.
public event EventHandler<MudDragAndDropItemTransaction<T>>? TransactionStarted