代码之家  ›  专栏  ›  技术社区  ›  François

显然,在没有实现ICommand的情况下,reactiveCommand如何从ICommand派生?

  •  0
  • François  · 技术社区  · 8 年前

    ReactiveUI ,班级 ReactiveCommand 从接口派生 ICommand .然而,它的公共API似乎没有实现 Execute CanExecute .

    这怎么可能呢?

    1 回复  |  直到 8 年前
        1
  •  4
  •   Kent Boogaart    8 年前

    ReactiveCommand 工具 ICommand explicitly ,这意味着您只能在变量类型为的情况下访问这些成员。 i命令 以下内容:

    ReactiveCommand<Unit, Unit> command = ...;
    
    // compile error
    command.Execute();
    
    // compiles fine
    (command as ICommand).Execute();
    

    这是为了鼓励你 使用它,因为反应式接口是优越的,但仍然有助于与依赖它的UI工具包(如WPF)集成。