Class MudFileUpload<T>
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
A form component for uploading one or more files. For T
, use either IBrowserFile
for a single file or IReadOnlyList<IBrowserFile>
for multiple files.
public class MudFileUpload<T> : MudFormComponent<T, string>, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IFormComponent, IAsyncDisposable, IActivatable
Type Parameters
T
Either IBrowserFile for a single file or IReadOnlyList<IBrowserFile> for multiple files.
- Inheritance
-
MudFileUpload<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
MudFileUpload()
Creates a new instance.
public MudFileUpload()
Properties
Accept
The accepted file extensions, separated by commas.
[Parameter]
[Category("Behavior")]
public string? Accept { get; set; }
Property Value
Remarks
Defaults to null
for any file type. Multiple file extensions must be separated by commas (e.g. ".png, .jpg"
).
ActivatorContent
The custom content which, when clicked, opens the file picker.
[Parameter]
[Category("Behavior")]
public RenderFragment? ActivatorContent { get; set; }
Property Value
AppendMultipleFiles
Appends additional files to the existing list.
[Parameter]
[Category("Behavior")]
public bool AppendMultipleFiles { get; set; }
Property Value
Remarks
Defaults to false
. This applies when T
is IReadOnlyList<IBrowserFile>.
Classname
protected string Classname { get; }
Property Value
Disabled
Prevents the user from uploading files.
[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }
Property Value
Remarks
Defaults to false
.
Files
The uploaded file or files.
[Parameter]
[Category("Behavior")]
public T? Files { get; set; }
Property Value
- T
Remarks
When T
is IBrowserFile, a single file is returned.
When T
is IReadOnlyList<IBrowserFile>, multiple files are returned.
FilesChanged
Occurs when Files has changed.
[Parameter]
[Category("Behavior")]
public EventCallback<T?> FilesChanged { get; set; }
Property Value
Hidden
Hides the inner InputFile component.
[Parameter]
[Category("Appearance")]
public bool Hidden { get; set; }
Property Value
Remarks
Defaults to true
. When false
, files can be uploaded via drag-and-drop.
InputClass
The CSS classes applied to the internal InputFile.
[Parameter]
[Category("Appearance")]
public string? InputClass { get; set; }
Property Value
Remarks
These styles apply when Hidden is false
. Multiple classes must be separated by spaces.
InputStyle
The CSS styles applied to the internal InputFile.
[Parameter]
[Category("Appearance")]
public string? InputStyle { get; set; }
Property Value
Remarks
These styles apply when Hidden is false
.
MaximumFileCount
The maximum number of files retrieved during a call to GetMultipleFiles(int).
[Parameter]
[Category("Behavior")]
public int MaximumFileCount { get; set; }
Property Value
Remarks
Defaults to 10
. This property does not limit the total number of uploaded files allowed; a limit should be validated manually, such as during the FilesChanged event.
OnFilesChanged
Occurs when the internal files have changed.
[Parameter]
[Category("Behavior")]
public EventCallback<InputFileChangeEventArgs> OnFilesChanged { get; set; }
Property Value
SelectedTemplate
The template used for selected files.
[Parameter]
[Category("Appearance")]
public RenderFragment<T?>? SelectedTemplate { get; set; }
Property Value
SuppressOnChangeWhenInvalid
Prevents raising OnFilesChanged if validation fails during an upload.
[Parameter]
[Category("Behavior")]
public bool SuppressOnChangeWhenInvalid { get; set; }
Property Value
Remarks
Defaults to false
.
Methods
Activate(object, MouseEventArgs)
Opens the file picker.
public void Activate(object activator, MouseEventArgs args)
Parameters
activator
objectThe object which raised the event.
args
MouseEventArgsThe coordinates of the mouse when clicked.
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
ClearAsync()
public Task ClearAsync()
Returns
GetDisabledState()
protected bool GetDisabledState()
Returns
OnInitialized()
protected override void OnInitialized()
OpenFilePickerAsync()
Opens the file picker.
public Task OpenFilePickerAsync()
Returns
ReadValue()
protected override T? ReadValue()
Returns
- T
WriteValueAsync(T?)
protected override Task WriteValueAsync(T? value)
Parameters
value
T