0
<Style TargetType="ComboBoxItem" x:Key="ComboBoxItemStyle">
            <EventSetter Event="Selected" Handler="status_SelectionChanged"/>
</Style>

status_SelectionChanged方法:

public void status_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    MessageBox.Show("1");
}

错误:无效 System.Windows.RoutedEventHandler

为什么?

4

2 回答 2

2

我相信您的 SelectionChanged 方法签名应该使用RoutedEventArgs e而不是SelectionChangedEventArgs e

这是显示 RoutedEventHandler 签名的 MSDN

于 2012-07-11T13:28:58.950 回答
0

尝试

private void status_SelectionChanged(object sender, RoutedEventArgs e)

请参见ListBoxItem.Selected

于 2012-07-11T13:30:06.377 回答