Skip to main content

DataFormat Class

Definition​

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

Represents a format usable with the clipboard and drag-and-drop.

public class DataFormat

Inheritance: object -> DataFormat

Derived types:DataFormat<T>

Implements: IEquatable<DataFormat>

Methods​

NameDescription
CreateBytesApplicationFormatCreates a new format specific to the application that returns an array of byte.
CreateBytesPlatformFormatCreates a new format for the current platform that returns an array of byte.
CreateInProcessFormatNo summary available.
CreateStringApplicationFormatCreates a new format specific to the application that returns a string.
CreateStringPlatformFormatCreates a new format for the current platform that returns a string.
Equals (2 overloads)No summary available.
GetHashCodeNo summary available.
ToStringNo summary available.
ToSystemNameCreates a name for this format, usable by the underlying platform.

CreateBytesApplicationFormat Method​

Creates a new format specific to the application that returns an array of byte.

public Avalonia.Input.DataFormat<T><byte[]> CreateBytesApplicationFormat(string identifier)

Parameters​

identifier string

The format identifier. To avoid conflicts with system identifiers, this value isn't passed to the underlying platform directly. However, two different applications using the same identifier with Avalonia.Input.DataFormat.CreateBytesApplicationFormat(string) or Avalonia.Input.DataFormat.CreateStringApplicationFormat(string) are able to share data using this format.

Only ASCII letters (A-Z, a-z), digits (0-9), the dot (.) and the hyphen (-) are accepted.

Returns​

Avalonia.Input.DataFormat<T><byte[]>

A new Avalonia.Input.DataFormat.

CreateBytesPlatformFormat Method​

Creates a new format for the current platform that returns an array of byte.

public Avalonia.Input.DataFormat<T><byte[]> CreateBytesPlatformFormat(string identifier)

Parameters​

identifier string

The format identifier. This value is not validated and is passed AS IS to the underlying platform. Most systems use mime types, but macOS requires Uniform Type Identifiers (UTI).

Returns​

Avalonia.Input.DataFormat<T><byte[]>

A new Avalonia.Input.DataFormat.

CreateInProcessFormat Method​

public Avalonia.Input.DataFormat<T><T> CreateInProcessFormat<T>(string identifier)

Parameters​

identifier string

Type Parameters​

T

Returns​

Avalonia.Input.DataFormat<T><T>

CreateStringApplicationFormat Method​

Creates a new format specific to the application that returns a string.

public Avalonia.Input.DataFormat<T><string> CreateStringApplicationFormat(string identifier)

Parameters​

identifier string

The format identifier. To avoid conflicts with system identifiers, this value isn't passed to the underlying platform directly. However, two different applications using the same identifier with Avalonia.Input.DataFormat.CreateBytesApplicationFormat(string) or Avalonia.Input.DataFormat.CreateStringApplicationFormat(string) are able to share data using this format.

Only ASCII letters (A-Z, a-z), digits (0-9), the dot (.) and the hyphen (-) are accepted.

Returns​

Avalonia.Input.DataFormat<T><string>

A new Avalonia.Input.DataFormat.

CreateStringPlatformFormat Method​

Creates a new format for the current platform that returns a string.

public Avalonia.Input.DataFormat<T><string> CreateStringPlatformFormat(string identifier)

Parameters​

identifier string

The format identifier. This value is not validated and is passed AS IS to the underlying platform. Most systems use mime types, but macOS requires Uniform Type Identifiers (UTI).

Returns​

Avalonia.Input.DataFormat<T><string>

A new Avalonia.Input.DataFormat.

Equals overloads​

Equals Method​

public bool Equals(Avalonia.Input.DataFormat other)
Parameters​

other Avalonia.Input.DataFormat

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

GetHashCode Method​

public int GetHashCode()

Returns​

int

ToString Method​

public string ToString()

Returns​

string

ToSystemName Method​

Creates a name for this format, usable by the underlying platform.

public string ToSystemName(string applicationPrefix)

Parameters​

applicationPrefix string

The system prefix used to recognize the name as an application format.

Returns​

string

A system name for the format.

Remarks​

This method can only be called if Avalonia.Input.DataFormat.Kind is Avalonia.Input.DataFormatKind.Application or Avalonia.Input.DataFormatKind.Platform.

Properties​

NameDescription
BitmapGets a data format representing a bitmap. Its data type is Avalonia.Media.Imaging.Bitmap.
FileGets a data format representing a single file. Its data type is Avalonia.Platform.Storage.IStorageItem.
IdentifierGets the identifier of the data format.
KindGets the kind of the data format.
TextGets a data format representing plain text. Its data type is string.

Bitmap Property​

Gets a data format representing a bitmap. Its data type is Avalonia.Media.Imaging.Bitmap.

public Avalonia.Input.DataFormat<T><Avalonia.Media.Imaging.Bitmap> Bitmap { get; set; }

File Property​

Gets a data format representing a single file. Its data type is Avalonia.Platform.Storage.IStorageItem.

public Avalonia.Input.DataFormat<T><Avalonia.Platform.Storage.IStorageItem> File { get; set; }

Identifier Property​

Gets the identifier of the data format.

public string Identifier { get; set; }

Kind Property​

Gets the kind of the data format.

public Avalonia.Input.DataFormatKind Kind { get; set; }

Text Property​

Gets a data format representing plain text. Its data type is string.

public Avalonia.Input.DataFormat<T><string> Text { get; set; }