"WPF command support in ComboBox", this page shows how to extend a combobox to support a command, but it didn't give a dome of the delegate command that maps to the combobox's SelectedIndexChanged event. Now the problem I face is how can I handle the combobox SelectedIndexChanged event like where it is a one-off combobox situation :
<ComboBox SelectionChanged="ComboBox_SelectionChanged"></ComboBox>
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var combobox = sender as ComboBox;
if (combobox.SelectedIndex == 0)
{
//todo:
}
}
current situation is as below:
<GridViewColumn.CellTemplate>
<DataTemplate>
<Ext:CommandSupportedComboBox SelectedIndex="{Binding StartMode}"
Command="{Binding ChangeStartModeCmd}">
<ComboBoxItem>Automatically</ComboBoxItem>
<ComboBoxItem>Manual</ComboBoxItem>
<ComboBoxItem>Forbidden</ComboBoxItem>
</Ext:CommandSupportedComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
/// <summary>
/// change service start mode command
/// </summary>
public ICommand ChangeStartModeCmd { get; private set; }
and the corresponding delegate method :
/// <summary>
/// change service start mode
/// </summary>
public void ChangeStartMode()
{
//todo:
}
binding method to command:
ChangeStartModeCmd = new DelegateCommand(ChangeStartMode);
I want to define the method like this:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var combobox = sender as ComboBox;
if (combobox.SelectedIndex == 0)
{
//todo:
}
}
but how do I bind it to the delegate command ChangeStartModeCmd?
ChangeStartModeCmd = new DelegateCommand(ChangeStartMode(
/*what should I pass for the method?*/));