【问题标题】:Use ICommand in Portable Class Library that targets .net 4在面向 .net 4 的可移植类库中使用 ICommand
【发布时间】:2014-07-14 07:40:48
【问题描述】:

如果我创建一个以 .Net 4.0 为目标的可移植类库,我看不到任何可用的ICommand 接口(如果 PCL 以 .Net 4.5 ICommand 为目标)。

由于 ViewModel 广泛使用 ICommand,有没有办法在仍然使用 PCL 的同时共享它们?

我是否遗漏了什么,只是没有看到应该存在的 ICommand?

【问题讨论】:

    标签: c# wpf portable-class-library icommand


    【解决方案1】:

    请参阅this 链接。在 Supported features 部分,它显示 .Net Framework 低于 4.5 不支持 MVVM。

    这意味着如果您正在创建面向 .Net Framework 4.0 的 PCL,则不能使用任何 MVVM 功能,例如 ICommand

    【讨论】:

      【解决方案2】:

      是的,您必须使用 .Net 4.5 PCL。它包括“System.Windows.Input.ICommand”类 查看以下链接,了解 ICommand 在 .Net 4.5 中与 PCL 一起使用的示例。

      Using Portable Class Library with Model-View-View Model

      【讨论】:

      • 谢谢,正如我所提到的,我知道它完全适用于 .net 4.5。有没有办法让它在面向 .net 4.0 时工作?
      • 到目前为止,我认为没有任何方法可以在 4.0 中使用它,因为它是由 MS 在 4.5 中引入的。
      猜你喜欢
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-27
      • 2013-10-18
      • 1970-01-01
      相关资源
      最近更新 更多