New to Telerik UI for .NET MAUI? Start a free 30-day trial
.NET MAUI Button Command
The Telerik .NET MAUI Button 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
.
1. Define the Button in XAML:
xaml
<telerik:RadButton x:Name="button"
Text="Click me" />
2. Add the telerik
namespace:
XAML
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
3. Execute the Command
:
c#
this.button.Command = new Command(
execute: () =>
{
count++;
if (count == 1)
button.Text = $"Clicked {count} time";
else
button.Text = $"Clicked {count} times";
},
canExecute: () =>
{
return true;
});
This is the result on WinUI:
For a runnable example demonstrating the Button Command, see the SDKBrowser Demo Application and go to the Button > Features category.