我有一个绑定到ICommand的WPF窗口中的按钮

<Button Style="{StaticResource ToolBarButtonSearchTime}">
    <Button.Command>
        <Binding Path="FiltrarPlanillasCommand">
            <Binding.ValidationRules>
                <ExceptionValidationRule/>
            </Binding.ValidationRules>
        </Binding>
    </Button.Command>
</Button>


这是执行的方法

public void FiltrarPlanillasExecute(object p)
{
    FiltrosDocumento filtro = new FiltrosDocumento();
    filtro.ListaBodegasAcopio = ListaBodegasSeleccionadas;
    filtro.FechaInicial = FechaInicial;
    filtro.FechaFinal = FechaFinal;
    filtro.IntIdmodulo = IntIdModulo;
    try
    {
        filtro.PlanillaAcopioLiquidada = PlanillaAcopioLiquidada;

        ListaPlanillas = null;
        ListaPlanillas = new ObservableCollection<Merlin_MovimientoDocumentosFacturacion_Enc>(
                    ListaDocumentos.PlanillasAcopio(filtro, db)
                );
        ((DelegateCommand)_ICommandParadigmaNPrint).RaiseCanExecuteChanged();
    }
    catch (Exception)
    {
        //    Here this exception wasn't catched
        throw;
    }
}


为什么设置了<ExceptionValidationRule/>却没有捕获到异常?
我的代码有什么问题?

最佳答案

ExceptionValidationRule用于捕获在属性的set或get方法处发生的异常,而不是您绑定到的command属性的execute方法。

08-28 22:32