Skip to content
Rizan Zaky edited this page Jul 30, 2020 · 27 revisions

Toast Control

Namespace: DIPS.Xamarin.UI.Controls.Toast

A Toast view appears over the active page. Commonly used to give feedback to users of certain activities. The user can also interact with the Toast.

Only one Toast will be displayed at a given time in the active page. If a toast is set to display while there is a previous toast on screen, the previous toast will be closed immediately allowing way to display the new toast.

Source Code can be found here

Samples can be found here

👉 To get started, make sure you have followed the getting started steps

Example usage

Import the Toast control with the following using statement,

using DIPS.Xamarin.UI.Controls.Toast;

Initialize the Toast

First, the Toast control should be Initialized in the App.xaml.cs file.

public App()
{
    InitializeComponent();
    // some code
    Toast.Current.Initialize();
    // some code
}

Display the Toast

The DisplayToast method displays the Toast in the currently Active page. This method has two overloads.

Both methods intake a string, which will be the displayed Text. ToastOptions is used to set the basic options for the Toast and ToastLayout is used to define the layout of the Toast.

The first overload is,

var options = new ToastOptions();
var layout = new ToastLayout();

Toast.Current.DisplayToast(title, options, layout));

you can also display the toast using the other overloaded method,

Toast.Current.DisplayToast(title, options => { }, layout => { }));

Close the Toast

The following method simply closes the toast on screen.

Toast.Current.CloseToast();

ToastOptions

Look and feel

On iOS

On Android

Properties

Property Explanation Remarks default value
Current A static property holding an active Toast instance This is a static property new Toast()
Clone this wiki locally