InvokeCommandAction 不调用

InvokeCommandAction not calling

我有一个组合框,我的视图模型中需要一个命令来绑定到它的 ContextMenuOpening 事件。我已尝试引用 System.Windows.Interactivity 并使用 InvokeCommandAction,但命令未调用。有没有人看到我要去哪里错了?

<ComboBox x:Name="comboBoxAs" Grid.Column="0" VerticalAlignment="Top" Margin="928,62,0,0" Height="25"
            ItemsSource="{Binding Source={StaticResource sas}}"
            SelectedItem="{Binding Path=as, UpdateSourceTrigger=PropertyChanged}"
            Style="{StaticResource ComboBoxDefault}" HorizontalAlignment="Left" Width="212"   >

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="ContextMenuOpening">      

            <i:InvokeCommandAction Command="{Binding ContextMenuOpeningCommand, Mode=OneWay}" />

        </i:EventTrigger>
    </i:Interaction.Triggers>
</ComboBox>

视图模型:

public ICommand ContextMenuOpeningCommand
{
    get
    {
        if (_contextMenuOpeningCommand == null)
        {
            _contextMenuOpeningCommand = new RelayCommand<object>(param => this.ContextMenuOpening(),
                null);
        }

        return _contextMenuOpeningCommand;
    }
}

public void ContextMenuOpening()
{
    System.Windows.MessageBox.Show("test", "test");
}

private ICommand _contextMenuOpeningCommand;

请尝试使用 DropDownOpened 查看命令是否被命中。我试过了,它在这里有效。希望这有帮助:)