本文介绍了何时会引发Close.ExecuteCompleted - Event?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的事件有些问题,即this.Details.Commands.Close.ExecuteCompleted和相应的保存事件。我在屏幕背后有一些代码。在InitializeDataWorkspace上,我订阅了这两个事件。事实上,他们从来没有筹集过
(我设置了一些断点)。

I've some problems with your Events, namely this.Details.Commands.Close.ExecuteCompleted and the corresponding Save Event. I've some Code in the Screen-Behind. On InitializeDataWorkspace, I subscribe to these two events. As a matter of fact, they never get raised (I've set some breakpoints).

因此,我想知道这个特定事件何时会被提出......

Therefore, I'm wondering when this particular Event will be raised...

推荐答案

  partial void Method_Execute()

  {

   this.Details.Commands.Save.ExecuteCompleted += new EventHandler<ExecuteCompletedEventArgs>(Save_ExecuteCompleted);

   

   this.Details.Dispatcher.BeginInvoke( () =>

   {

    this.Details.Commands.Save.ExecuteAsync();

   });

  }



  void Save_ExecuteCompleted(object sender, ExecuteCompletedEventArgs e)

  {

   this.ShowMessageBox("Save_ExecuteCompleted");

  }



For the close command, it is a little different. Once the screen is closed, the screen object is gone and the ExectueCompleted event cannot be found anymore. You can try to define it in other places than the screen itself.


这篇关于何时会引发Close.ExecuteCompleted - Event?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 01:00