routed commands - WPF Commanding problem -


why commanded control disabled command can executed? command runs alt + f4

public static class commandlibrary {     static commandlibrary() {         shutdowncommand = new routeduicommand("exit", "exit", typeof(commandlibrary), new inputgesturecollection {new keygesture(key.f4, modifierkeys.alt)});     }      public static routeduicommand shutdowncommand { get; private set; }      public static void bindcommands(window hostwindow) {         if (hostwindow == null)             return;          hostwindow.commandbindings.add(new commandbinding(shutdowncommand, onshutdowncommandexecuted, onshutdowncommandcanexecute));     }      private static void onshutdowncommandexecuted(object sender, executedroutedeventargs e) {         messagebox.show("shutdown excuted!");     }      private static void onshutdowncommandcanexecute(object sender, canexecuteroutedeventargs e) {         e.canexecute = true;     } }  <menuitem command="local:commandlibrary.shutdowncommand" /> 

usually happens because there's no commandbinding command in scope of control has command set on it. if set breakpoint in canexecute handler hit menuitem?


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -