Binding Commands to ComboBoxItem in WPF

Viewed 10437

I have a simple ComboBox that I want to trigger separate commands each time the selected value changes. Here is an example of my markup:

<WrapPanel Grid.Row="0" Visibility="{Binding ShowToggleViewFeedViewManual}">
    <ComboBox Margin="3,3,0,0">
        <ComboBoxItem IsEnabled="{Binding CanSelectViewFeedData}" >
            <ComboBoxItem.CommandBindings>
                <CommandBinding Command="SelectViewFeedDataCommand" />
            </ComboBoxItem.CommandBindings>
            <TextBlock Text="View Feed Data"/>
        </ComboBoxItem>
        <ComboBoxItem IsEnabled="{Binding CanSelectViewManualData}">
            <ComboBoxItem.CommandBindings>
                <CommandBinding Command="SelectManualFeedDataCommand" />
            </ComboBoxItem.CommandBindings>
            <TextBlock Text="View Manual Data"/>
        </ComboBoxItem>
    </ComboBox>
</WrapPanel>   

I get an error stating "Cannot convert 'SelectViewFeedDataCommand'". I get a similar error for the other ComboBoxItem as well. The ICommand is defined in the ViewModel Class that is the DataSource for the UserControl, bound as a DataTemplate.

public ICommand SelectViewFeedDataCommand
{
    get
    {
        // Code to perform
    }
}

I have researched this pretty extensively but haven't found an answer for how to effectively bind the ICommand to the ComboBoxItem.

I am adapting this from existing code that used a set of radiobuttons and associated commands, which is done pretty easily. Is there no simple way to do this with a ComboBox?

Thanks.

2 Answers
Related