When is CanExecute called?

前端 未结 4 2016
离开以前
离开以前 2020-11-29 10:41

In the demo, I have a button to toggle a bool field isAsking. I create a command which can execute only when isAsking==true.

Once I press T

4条回答
  •  半阙折子戏
    2020-11-29 11:21

    I try to search for "the CommandManager detects conditions" and reach this exellent article.

    By examining .NET Framework source code, the author finds that the CommandManager doesn't detect conditions by itself, rather than when Keyboard.KeyUpEvent, Mouse.MouseUpEvent, Keyboard.GotKeyboardFocusEvent, or Keyboard.LostKeyboardFocusEvent occurs, it will reevaluate CanExecute method.

    The article includes other information, but the above part has been enough for me.

提交回复
热议问题