mvvm light - RelayCommands overriding the "IsEnabled" of my buttons -


relaycommands overriding "isenabled" of buttons.

is bug? here xaml view , code viewmodel

<button grid.column="0" content="clear" isenabled="false" cmd:buttonbaseextensions.command="{binding clearcommand}"  />      public relaycommand clearcommand     {        { return new relaycommand(() => messagebox.show("clear command")); }     } 

notice hardcoded isenabled="false" in xaml. value ignored (button enabled).

i realize relaycommand have canexecute overload did want use want more have disabled button.

that's interesting point. right, isenabled property gets overriden. guess improvement ignore isenabled property if canexecute delegate not set in constructor... consider in next version.

in mean time, use canexecute delegate , set return false always.

public relaycommand clearcommand {    { return new relaycommand(        () => messagebox.show("clear command"),        () => false); } } 

cheers, laurent


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -