I am working on a Custom Control that Consists of a ComboBox and a Button to the right as the image below.

My code for allowing Commands to be Bound to the Button is:
private Button _SearchButton;
// events exposed to container
public static readonly RoutedEvent SearchClickEvent =
EventManager.RegisterRoutedEvent("SearchClick", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(SearchComboBox));
// get the button objects as the templete is applied and add click event handlers
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_SearchButton = GetTemplateChild("SearchButton") as Button;
if (_SearchButton != null) _SearchButton.Click += SearchButtonClicked;
this.Loaded += SearchComboBox_Loaded;
}
// expose and raise 'SearchClick' event
public event RoutedEventHandler SearchClick
{
add { AddHandler(SearchClickEvent, value); }
remove { RemoveHandler(SearchClickEvent, value); }
}
private void SearchButtonClicked(object sender, RoutedEventArgs e)
{
RaiseEvent(new RoutedEventArgs(SearchClickEvent));
}
private void SearchComboBox_Loaded(object sender, RoutedEventArgs e)
{
if (MaxDropDownWidth == 0)
{
MaxDropDownWidth = this.ActualWidth;
}
}
#endregion Routed Event
#region Search Button Command
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command",
typeof(ICommand), typeof(SearchComboBox), new PropertyMetadata(null, OnCommandPropertyChanged));
private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
SearchComboBox? control = d as SearchComboBox;
if (control == null) return;
control.SearchClick -= SearchButtonClick;
control.SearchClick += SearchButtonClick;
}
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
private static void SearchButtonClick(object sender, RoutedEventArgs e)
{
SearchComboBox? control = sender as SearchComboBox;
if (control == null || control.Command == null) return;
ICommand command = control.Command;
if (command.CanExecute(null))
command.Execute(null);
}
#endregion Search Button Command
I Would also like to have the option to pass a CommandParameter but I am struggling with this. Any assistance would be much appreciated.