2

我有一个按钮进入绑定到 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/>已设置,它不会捕获异常?我的代码有什么问题?

4

1 回答 1

0

ExceptionValidationRule 用于捕获属性的 set 或 get 方法发生的异常,而不是您绑定到的命令属性的执行方法。

于 2013-10-09T14:57:37.990 回答