# .NET MAUI DropDownButton Command

The Telerik .NET MAUI DropDownButton 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 DropDownButton on click.

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

```XAML
<telerik:RadDropDownButton Content="{Binding ButtonText}"
                           Command="{Binding ToggleCommand}">
    <telerik:RadDropDownButton.DropDownContent>
        <Label Text="{Binding StatusText}"
               Padding="8" />
    </telerik:RadDropDownButton.DropDownContent>
</telerik:RadDropDownButton>
```

**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 buttonText = "Click to open drop-down";
    private string statusText = "The Command has not been executed yet.";
    private int clickCount;

    public ViewModel()
    {
        this.ToggleCommand = new Microsoft.Maui.Controls.Command(this.OnToggleExecute);
    }

    public Microsoft.Maui.Controls.Command ToggleCommand { get; }

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

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

    private void OnToggleExecute(object parameter)
    {
        this.clickCount++;
        this.ButtonText = $"Clicked {this.clickCount} time(s)";
        this.StatusText = $"Command executed. Click count: {this.clickCount}.";
    }
}
```

This is the result on WinUI:

![.NET MAUI DropDownButton Command](https://www.telerik.com/maui-ui/documentation/assets/2c24b757077896843434f3e49b5efaaa/dropdownbutton-command.gif "DropDownButton for .NET MAUI")

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

## See Also

* [Configure the Button Content and Indicator](https://www.telerik.com/maui-ui/documentation/controls/dropdownbutton/button-configuration)
* [Configure the Drop-Down Part](https://www.telerik.com/maui-ui/documentation/controls/dropdownbutton/dropdown-configuration)
* [Style the DropDownButton](https://www.telerik.com/maui-ui/documentation/controls/dropdownbutton/styling)
* [Events](https://www.telerik.com/maui-ui/documentation/controls/dropdownbutton/events)
* [Animation](https://www.telerik.com/maui-ui/documentation/controls/dropdownbutton/animation)
