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

Button

The RadButton control inherits from the Button control and implements the ICommandSource interface. Because of the inheritance it has all of the features that the standard Button control has. Moreover, the ICommandSource implementation allows you to attach commands to the button, which will get executed when it gets clicked.

To learn more about the members of the RadButton class, you can read here.

To learn how to use it with commands you should read the Commands topic.

Instantiating RadButton

You can instantiate your RadButton in both XAML and code. Here is an example:

The RadButton control is located in the Telerik.Windows.Controls.dll and in order to use it in your project you have to add a reference to the assembly. You can find more info here.
Then in XAML you have to declare the namespace: xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

Example 1: Defining a button in XAML

<telerik:RadButton Content="Click Me!" /> 

Example 2: Defining a button in code

RadButton radButton = new RadButton(){Content = "Click Me!"}; 
Dim radButton As New RadButton() With { _ 
    .Content = "Click Me!" _ 
} 

Figure 1: The created button

The created button

Handling the Button Click

If you want to implement custom logic to be executed when the button is clicked, you can either:

  • handle the Click event.

or

  • use Commands.

You can see how to use commands in the Commands article.

Here is an example of handling the Click event of a button.

Example 3: Subscribing to the Click event

<telerik:RadButton Content="Click Me!" Click="RadButton_Click" /> 

Example 4: Defining a Click event handler

private void RadButton_Click(object sender, RoutedEventArgs e) 
{ 
    //implement your logic here 
} 
Private Sub RadButton_Click(sender As Object, e As RoutedEventArgs) 
    'implement your logic here' 
End Sub 

Customizing the RadButton

  • IsBackgroundVisible - this property is of type bool and it controls the visibility of the background and the border of the RadButton control in normal state

    Figure 2: A button with a hidden background

    A button with a hidden background

  • CornerRadius - this property is of type CornerRadius and it controls the CornerRadius of the RadButton control

    Figure 3: A button with its CornerRadius set to 15

    A button with its CornerRadius set to 15

See Also

In this article