You can add a custom behavior that attaches to the combobox and subscribes to selection changed.
using System.Windows.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.Xaml.Interactivity;
namespace StackOverflowWin81
{
public class SelectionChangedCommandBehavior : DependencyObject, IBehavior
{
private ComboBox _comboBox;
public void Attach(DependencyObject associatedObject)
{
//set attached object
_comboBox = associatedObject as ComboBox;
//subscribe to event
_comboBox.SelectionChanged += _comboBox_SelectionChanged;
}
private void _comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//execute the command
if (this.Command.CanExecute(null))
{
Command.Execute(null);
}
}
public void Detach()
{
_comboBox.SelectionChanged -= _comboBox_SelectionChanged;
}
public DependencyObject AssociatedObject { get; private set; }
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof (ICommand), typeof (SelectionChangedCommandBehavior), new PropertyMetadata(default(ICommand)));
public ICommand Command
{
get { return (ICommand) GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
}
}