天天看點

WPF中ICommand接口 的一個設計問題

    按照msdn中的解釋,當canexecutechanged事件發生時,icommandsource會調用icommand的canexecute方法來檢測是否可以執行指令。如果是這樣,這裡的這個事件名取為:類似“canexecuteconditionchanged”不是更好嗎?

    因為canexecutechanged發生,使用者的第一感覺就是canexecute從false變到true或者由true變到false了。

    關于這個設計問題,我想不出原因,是以希望高人解釋下。:)

    另外,還有一個小問題,msdn中說到:

in the windows presentation foundation (wpf) commanding system, the commandtarget property on a icommandsource is only applicable when the icommand is a routedcommand. if the commandtarget is set on a icommandsource and the corresponding command is not a routedcommand, the command target is ignored.

    那麼,設計這個屬性會不會有點多餘?雖然我覺得加上也是好的。

繼續閱讀