Change Blazor Toggle Switch Button state using toggle method

4 Aug 20211 minute to read

This section explains about how to toggle between the Toggle Switch Button states using Toggle method.

@using Syncfusion.Blazor.Buttons

<SfSwitch @bind-Checked="isChecked" OffLabel="OFF" OnLabel="ON" Created="create" @ref="SwitchObj" TChecked="bool"></SfSwitch>

@code{
    private bool isChecked = false;
    SfSwitch<bool> SwitchObj;
    private void create(object obj)
    {
        //SwitchObj.Toggle();
    }
}

Output be like

Switch Sample

Switch triggers OnChange event on every state stage to perform custom operations.