C# PRISM WPF CompositeCommand执行方法不工作
我有一个moduleA,它需要在moduleB的ViewModel中执行代码。因此,我在我的基础设施中创建了一个commandProxy,并在moduleB中注册了一个命令。当我在proxy命令上调用Execute时,注册的命令不会执行。我应该如何进行调试 模C# PRISM WPF CompositeCommand执行方法不工作,c#,wpf,prism,C#,Wpf,Prism,我有一个moduleA,它需要在moduleB的ViewModel中执行代码。因此,我在我的基础设施中创建了一个commandProxy,并在moduleB中注册了一个命令。当我在proxy命令上调用Execute时,注册的命令不会执行。我应该如何进行调试 模 commandProxy.ShowOrderCommand.Execute(""); // I can see the registered command in the debugger //This is obtained throu
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; }
}
}
我错过了委托命令中的函数定义
showOrderDetailsCommand=新的DelegateCommand(ShowOrderDetailsView,SubmitAllCanExecute) 您不能使用
EventAggregators
而不是命令吗。您可以订阅模块B中的事件,并在需要时从模块A发布该事件。这比在适当的位置使用命令容易得多。