Updated title: Why ICommand.CanExecute is getting called all the time, instead of working like an event?

后端 未结 3 1036
轮回少年
轮回少年 2021-02-09 13:58

I am adopting MVVM pattern in WPF and have learned the use of Command. But in my implementation, the delegate I assigned to implement CanExecute is alw

3条回答
  •  迷失自我
    2021-02-09 14:46

    May be for unknown reason the UI could be getting updated (Measure, Arrange, and then Render calls). And if you have a breakpoint set on can execute method it'll be re-occurring. In other words you can't get pass this break point, each time you would do F5, the break point will it again.

    To investigate you should put the logging/output statements in your can execute method and how many times and when it is getting called.

提交回复
热议问题