Reputation: 623
I am trying to bind the SelectionChanged event of ComboBox using RoutingCommand(same as we bind the command for Buttons). But not able to achieve it. I dnt like to use any third party control or to write the code in the property.
Upvotes: 0
Views: 2823
Reputation: 13640
You can use System.Windows.Interactivity
dll.
The code will be something like that:
<UserControl
...
xmlns:ei="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
...>
...
<Combobox>
<ei:Interaction.Triggers>
<ei:EventTrigger EventName="SelectionChanged">
<ei:InvokeCommandAction Command="{Binding Command}"/>
</ei:EventTrigger>
</ei:Interaction.Triggers>
</Combobox>
...
</UserControl>
Upvotes: 1
Reputation: 720
Are you sure, that you need SelectionChanged event? Just bind
SelectedItem="{Binding Path=ComboSelected, Mode=TwoWay}"
Where ComboSelected is property of your ViewModel. And do in setter of ComboSelected property what you need.
Upvotes: 1