Table of Contents

Interface IClipboard

Namespace
Avalonia.Input.Platform
Assembly
Avalonia.Base.dll
[NotClientImplementable]
public interface IClipboard

Methods

ClearAsync()

Clears any data from the system Clipboard.

Task ClearAsync()

Returns

Task

FlushAsync()

Permanently adds the data that is on the Clipboard so that it is available after the data's original application closes.

Task FlushAsync()

Returns

Task

Remarks

This method works only on Windows platform, on other platforms it does nothing.

GetDataAsync(string)

Retrieves data in a specified format from the Clipboard.

Task<object?> GetDataAsync(string format)

Parameters

format string

A string that specifies the format of the data to retrieve. For a set of predefined data formats, see the DataFormats class.

Returns

Task<object>

GetFormatsAsync()

Get list of available Clipboard format.

Task<string[]> GetFormatsAsync()

Returns

Task<string[]>

GetTextAsync()

Returns a string containing the text data on the Clipboard.

Task<string?> GetTextAsync()

Returns

Task<string>

A string containing text data in the specified data format, or an empty string if no corresponding text data is available.

SetDataObjectAsync(IDataObject)

Places a specified non-persistent data object on the system Clipboard.

Task SetDataObjectAsync(IDataObject data)

Parameters

data IDataObject

A data object (an object that implements IDataObject) to place on the system Clipboard.

Returns

Task

Exceptions

ArgumentNullException

data is null.

SetTextAsync(string?)

Stores text data on the Clipboard. The text data to store is specified as a string.

Task SetTextAsync(string? text)

Parameters

text string

A string that contains the UnicodeText data to store on the Clipboard.

Returns

Task

Exceptions

ArgumentNullException

text is null.

TryGetInProcessDataObjectAsync()

If clipboard contains the IDataObject that was set by a previous call to SetDataObjectAsync(IDataObject), return said IDataObject instance. Otherwise, return null. Note that not every platform supports that method, on unsupported platforms this method will always return null

Task<IDataObject?> TryGetInProcessDataObjectAsync()

Returns

Task<IDataObject>