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

How to set the Command property of the button part


Product Version 2019.2.618
Product RadButtons for WPF


How to bind the Command property of the RadButton element(the left part) inside the RadSplitButton.


Handle the Loaded event of the RadSplitButton, use the ChildrenOfType extension method in order to locate its RadButton child and set its Command property.

Example 1: Setting the Command of the RadButton inside the RadSplitButton

private void RadSplitButton_Loaded(object sender, RoutedEventArgs e) 
    var splitButton = (RadSplitButton)sender; 
    var buttonPart = splitButton.ChildrenOfType<RadButton>().FirstOrDefault(x => x.Name == "ButtonPart"); 
    if (buttonPart != null) 
        buttonPart.Command = new DelegateCommand(OnExecute, OnCanExecute); 
private bool OnCanExecute(object obj) 
    // If this method returns false, only the button part of the RadSplitButton will be disabled 
    return true; 
private void OnExecute(object obj) 
    MessageBox.Show("Button clicked!"); 
Private Sub RadSplitButton_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) 
    Dim splitButton = DirectCast(sender, RadSplitButton) 
    Dim buttonPart = splitButton.ChildrenOfType(Of RadButton)().FirstOrDefault(Function(x) x.Name = "ButtonPart") 
    If buttonPart IsNot Nothing Then 
        buttonPart.Command = New DelegateCommand(AddressOf OnExecute, AddressOf OnCanExecute) 
    End If 
End Sub 
Private Function OnCanExecute(ByVal obj As Object) As Boolean 
    ' If this method returns False, only the button part of the RadSplitButton will be disabled 
    Return True 
End Function 
Private Sub OnExecute(ByVal obj As Object) 
    MessageBox.Show("Button clicked!") 
End Sub 

See Also

In this article