Skip to main content

DataTransferItem Class

Definition

Namespace:Avalonia.Input
Assembly:Avalonia.Base
Package:Avalonia

A mutable implementation of Avalonia.Input.IDataTransferItem and Avalonia.Input.IAsyncDataTransferItem. This class also provides several static methods to easily create a Avalonia.Input.DataTransferItem for common usages.

public class DataTransferItem

Inheritance: object -> DataTransferItem

Remarks

While it also implements Avalonia.Input.IAsyncDataTransferItem, this class always returns data synchronously. For advanced usages, consider implementing Avalonia.Input.IAsyncDataTransferItem directly.

Constructors

NameDescription
DataTransferItemNo summary available.

DataTransferItem Constructor

public DataTransferItem()

Methods

NameDescription
Create (2 overloads)No summary available.
CreateFileCreates a new Avalonia.Input.DataTransferItem with Avalonia.Input.DataFormat.File as a single format.
CreateTextCreates a new Avalonia.Input.DataTransferItem with Avalonia.Input.DataFormat.Text as a single format.
Set (2 overloads)No summary available.
SetBitmapSets the value for the Avalonia.Input.DataFormat.Bitmap format.
SetFileSets the value for the Avalonia.Input.DataFormat.File format.
SetTextSets the value for the Avalonia.Input.DataFormat.Text format.
TryGetRawTries to get a value for a given format.

Create overloads

Create Method

public Avalonia.Input.DataTransferItem Create<T>(Avalonia.Input.DataFormat<T><T> format, Func<T> getValue)
Parameters

format Avalonia.Input.DataFormat<T><T>

getValue Func<T>

Type Parameters

T

Returns

Avalonia.Input.DataTransferItem

Create Method

public Avalonia.Input.DataTransferItem Create<T>(Avalonia.Input.DataFormat<T><T> format, T value)
Parameters

format Avalonia.Input.DataFormat<T><T>

value T

Type Parameters

T

Returns

Avalonia.Input.DataTransferItem

CreateFile Method

Creates a new Avalonia.Input.DataTransferItem with Avalonia.Input.DataFormat.File as a single format.

public Avalonia.Input.DataTransferItem CreateFile(Avalonia.Platform.Storage.IStorageItem value)

Parameters

value Avalonia.Platform.Storage.IStorageItem

The value corresponding to the Avalonia.Input.DataFormat.File format. If null, the format won't be part of the Avalonia.Input.DataTransferItem.

Returns

Avalonia.Input.DataTransferItem

A Avalonia.Input.DataTransferItem instance.

CreateText Method

Creates a new Avalonia.Input.DataTransferItem with Avalonia.Input.DataFormat.Text as a single format.

public Avalonia.Input.DataTransferItem CreateText(string value)

Parameters

value string

The value corresponding to the Avalonia.Input.DataFormat.Text format. If null, the format won't be part of the Avalonia.Input.DataTransferItem.

Returns

Avalonia.Input.DataTransferItem

A Avalonia.Input.DataTransferItem instance.

Set overloads

Set Method

public void Set<T>(Avalonia.Input.DataFormat<T><T> format, Func<T> getValue)
Parameters

format Avalonia.Input.DataFormat<T><T>

getValue Func<T>

Type Parameters

T

Set Method

public void Set<T>(Avalonia.Input.DataFormat<T><T> format, T value)
Parameters

format Avalonia.Input.DataFormat<T><T>

value T

Type Parameters

T

SetBitmap Method

Sets the value for the Avalonia.Input.DataFormat.Bitmap format.

public void SetBitmap(Avalonia.Media.Imaging.Bitmap value)

Parameters

value Avalonia.Media.Imaging.Bitmap

The value corresponding to the Avalonia.Input.DataFormat.Bitmap format. If null, the format won't be part of the Avalonia.Input.DataTransferItem.

SetFile Method

Sets the value for the Avalonia.Input.DataFormat.File format.

public void SetFile(Avalonia.Platform.Storage.IStorageItem value)

Parameters

value Avalonia.Platform.Storage.IStorageItem

The value corresponding to the Avalonia.Input.DataFormat.File format. If null, the format won't be part of the Avalonia.Input.DataTransferItem.

SetText Method

Sets the value for the Avalonia.Input.DataFormat.Text format.

public void SetText(string value)

Parameters

value string

The value corresponding to the Avalonia.Input.DataFormat.Text format. If null, the format won't be part of the Avalonia.Input.DataTransferItem.

TryGetRaw Method

Tries to get a value for a given format.

public object TryGetRaw(Avalonia.Input.DataFormat format)

Parameters

format Avalonia.Input.DataFormat

The format to retrieve.

Returns

object

A value for format, or null if the format is not supported.

Remarks

Implementations of this method are expected to return a value matching the exact type of the generic argument of the underlying Avalonia.Input.DataFormat<T>.

To retrieve a typed value, use Avalonia.Input.DataTransferItemExtensions.TryGetValue<T>(Avalonia.Input.IDataTransferItem,Avalonia.Input.DataFormat{<>}).

See also

Properties

NameDescription
FormatsGets the formats supported by this item.

Formats Property

Gets the formats supported by this item.

public System.Collections.Generic.IReadOnlyList<Avalonia.Input.DataFormat> Formats { get; set; }