# .NET MAUI TemplatedButton Command

The Telerik .NET MAUI TemplatedButton allows you to attach a command that executes when the button is clicked.

* `Command` (`ICommand`)—Defines the command which executes when the button is clicked.
* `CommandParameter` (`object`)—Specifies the parameter of the command which executes when the button is clicked.

## Using the Command

The following example demonstrates how to use the `Command` to change the text displayed within the ToggledButton on click.

**1.** Define the TemplatedButton in XAML:

```XAML
<VerticalStackLayout HorizontalOptions="Center">
    <telerik:RadTemplatedButton Content="{Binding MyText, Mode=TwoWay}" 
                                Command="{Binding MyTemplatedButtonCommand}"/>
    <VerticalStackLayout.BindingContext>
        <local:ViewModel/>
    </VerticalStackLayout.BindingContext>
</VerticalStackLayout>
```

**2.** Add the `telerik` namespace:

```XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
```

**3.** Add the `ViewModel`:

```C#
public class ViewModel : NotifyPropertyChangedBase
{
    private string myText = "Click to change content";

    public ViewModel()
    {
        this.MyTemplatedButtonCommand = new Microsoft.Maui.Controls.Command(this.CommandExecute);
    }

    public Microsoft.Maui.Controls.Command MyTemplatedButtonCommand { get; set; }

    public string MyText 
    { 
        get => this.myText;
        set { this.UpdateValue(ref this.myText, value); }
    }

    private void CommandExecute(object p)
    {
        this.MyText = "Content Changed";
        Application.Current.Windows[0].Page.DisplayAlert("", "Command is executed and TemplatedButton Content is changed", "OK");
    }
}
```

This is the result on WinUI:

![.NET MAUI TemplatedButton Command](https://www.telerik.com/maui-ui/documentation/assets/badf7e3352ab68943d8ffe84130c44c1/templatedbutton-command.gif "TemplatedButton for .NET MAUI")

> For a runnable example demonstrating the TemplatedButton Command, see the [SDKBrowser Demo Application](https://www.telerik.com/maui-ui/documentation/demos-and-sample-apps/sdkbrowser-app) and go to the **TemplatedButton > Features** category.

## See Also

* [Configure the TemplatedButton](https://www.telerik.com/maui-ui/documentation/controls/templatedbutton/configuration)
* [Loading Button](https://www.telerik.com/maui-ui/documentation/controls/templatedbutton/loading-button)
* [Set Visual States](https://www.telerik.com/maui-ui/documentation/controls/templatedbutton/visual-states)
* [Events](https://www.telerik.com/maui-ui/documentation/controls/templatedbutton/events)
* [Style the TemplatedButton](https://www.telerik.com/maui-ui/documentation/controls/templatedbutton/styling)
