【问题标题】:PRISM WPF CompositeCommand Execute method not workingPRISM WPF CompositeCommand Execute 方法不起作用
【发布时间】:2015-10-21 13:01:18
【问题描述】:

我有一个 moduleA 需要在 moduleB 的 ViewModel 中执行代码。所以我在我的基础设施中创建了一个 commandProxy,并在 moduleB 中注册了一个命令。当我在 proxyCommand 上调用 Execute 时,注册的命令不会执行。应该怎么调试?

模块A

commandProxy.ShowOrderCommand.Execute(""); // I can see the registered command in the debugger
//This is obtained through constructor injection

模块B

showOrderDetailsCommand = new DelegateCommand(() => { }, SubmitAllCanExecute);
commandProxy.ShowOrderCommand.RegisterCommand(showOrderDetailsCommand);

private void ShowOrderDetailsView()
        {
            _regionManager.RequestNavigate(RegionNames.SecondaryRegion, new Uri("/TradeLogView", UriKind.Relative));
        }

基础设施

private static CompositeCommand showOrderDetailsCommand = new CompositeCommand(true);

public class PostMatchCommandProxy
    {
        virtual public CompositeCommand ShowOrderCommand
        {
            get { return ShowOrderDetailsCommand; }
        }
    }

【问题讨论】:

  • 你不能用EventAggregators代替命令。您可以订阅模块 B 中的事件,并在模块 A 需要时发布事件。这比使用命令更容易。

标签: c# wpf prism


【解决方案1】:

我错过了委托命令中的函数定义

showOrderDetailsCommand = new DelegateCommand(ShowOrderDetailsView, SubmitAllCanExecute);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多