小编use*_*279的帖子

当前上下文中不存在名称"CommandManager"(Visual Studio 2015)

尝试使用下面的RelayCommand类我收到错误消息:"名称"CommandManager"在当前上下文中不存在".根据这篇文章,类库无法识别CommandManager类,我试图通过在"添加引用"上添加一个名为PresentationCore的程序集来解决问题.不幸的是"机器上没有找到框架组件".我卸载了Microsoft.NETCore.UniversalWindowsPlatform并按照一些帖子中的建议重新安装它,我修复了Visual Studio,但这并没有改变任何东西.这是我的失败还是一个错误?作为一个新手,我总是倾向于认为我忽略了一些东西;-)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace MyApplication.Viewmodels
{
public class RelayCommand : ICommand
{
    private readonly Action<object> _Execute;
    private readonly Func<object, bool> _CanExecute;

    public RelayCommand(Action<object> execute)
        : this(execute, null)
    {

    }

    public RelayCommand(Action<object> execute, Func<object, bool> canExecute)
    {
        if (execute == null)
        {
            throw new ArgumentNullException("execute", "Execute cannot be null.");
        }

        _Execute = execute;
        _CanExecute = canExecute;
    }

    public event EventHandler CanExecuteChanged
    {
        add { CommandManager.RequerySuggested += value; } …
Run Code Online (Sandbox Code Playgroud)

c# relaycommand visual-studio-2015

8
推荐指数
2
解决办法
2900
查看次数

标签 统计

c# ×1

relaycommand ×1

visual-studio-2015 ×1