什么在WinRT中替换命令管理? [英] What replaces CommandManager in WinRT?

查看:127
本文介绍了什么在WinRT中替换命令管理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用Metro风格的应用程序(我知道我们不应该把它称为地铁,但我永远记得它应该被称为......),而且我实施 DelegateCommand 类为MVVM使用。在WPF中, ICommand.CanExecuteChanged 事件通常是这样实现的:

I'm getting started with Metro style applications (I know we're not supposed to call it Metro, but I can never remember what it's supposed to be called...), and I'm implementing a DelegateCommand class for use in MVVM. In WPF, the ICommand.CanExecuteChanged event is typically implemented like this:

    public event EventHandler CanExecuteChanged
    {
        add { CommandManager.RequerySuggested += value; }
        remove { CommandManager.RequerySuggested -= value; }
    }



命令管理类中不存在的WinRT ...有什么别的呢?或者,我们应该明确地触发此事件自己呢?

But the CommandManager class does not exist in WinRT... Is there something else instead? Or are we supposed to explicitly trigger this event ourselves?

推荐答案

在WinRT中,必须更新/手动加注CanExecuteChanged。没有命令管理要做到这一点全球。你可以看看这个在颈部疼痛,现在还是一个严重的性能提升是CanExecute不是不断呼吁。它意味着你要想想级联属性更改的地方之前,你没得。但是,这是怎么回事。手册。

In WinRT, you must update/raise CanExecuteChanged manually. There is no CommandManager to do this globally. You could look at this as a pain in the neck, or a serious performance boost now that CanExecute is not called constantly. It does mean you have to think about cascading property changes where before you did not have to. But this is how it is. Manual.

public void RaiseCanExecuteChanged()
{
    if (CanExecuteChanged != null)
        CanExecuteChanged(this, EventArgs.Empty);
}

这篇关于什么在WinRT中替换命令管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆