New to Telerik UI for Blazor? Download free 30-day trial

Events

The ToolBar exposes events for its built-in buttons which allow you to react when the user perform actions on them. Such actions would be a click event or changing the selected state for the toggle button. The available events are:

For custom (templated) items, handle the corresponding events exposed by the components/elements you place inside them.

OnClick

The OnClick event fires when the user clicks on a button in the ToolBar (also applicable to toggle buttons).

The OnClick event for the ToolBar buttons

@*When clicking on the button a message will be printed in your console*@

<TelerikToolBar>
    <ToolBarButton Icon="hyperlink-email" OnClick="@OnHyperlinkClick">Hyperlink</ToolBarButton>
</TelerikToolBar>


@code {
    public void OnHyperlinkClick()
    {
        Console.WriteLine("The user clicked on the hyperlink button");
    }
}

SelectedChanged

The SelectedChanged event will fire when the user changes the state of the ToolBarToggleButton. It is used for one-way data binding of the Selected parameter and will prevent you from using two-way data binding (@bind-Selected)

The SelectedChanged event for the ToolBarToggleButton

@*Handle the SelectedChangedEvent*@

<TelerikToolBar>
    <TelerikToggleButton Selected="@Selected" SelectedChanged="@SelectedChangedHandler"></TelerikToggleButton>

</TelerikToolBar>


@code {
    public bool Selected { get; set; }

    public void SelectedChangedHandler(bool value)
    {
        Selected = value;

        //your application logic regarding the change of the value
    }
}

See Also

In this article
Not finding the help you need? Improve this article