我有一個自定義命令:WPF命令控制可視性
public static class CommandLibrary
{
private static RoutedUICommand cmdMyCommand = new RoutedUICommand("My command", "MyCommand", typeof(CommandLibrary));
public static RoutedUICommand MyCommand{ get { return cmdMyCommand ; } }
}
和我這樣註冊
CommandManager.RegisterClassCommandBinding(typeof(SomeClass), new CommandBinding(CommandLibrary.MyCommand, new ExecutedRoutedEventHandler(myCommandExecuteHandler), new CanExecuteRoutedEventHandler(myCommandCanExecuteHandler)));
一個有約束力和generic.xaml我有一個布頓使用Command屬性集。基於myCommandCanExecuteHandler中的邏輯正在啓用/禁用該按鈕。
但現在我想也控制此按鈕的可見性(獨立於映射到IsEnabled的CanExecute)。我如何解決這個問題?
關於同一個問題的討論可以在這裏找到:http://social.msdn.microsoft.com/forums/en-US/wpf/thread/c20782f8-2d04-49d3-b822-f77b4b87c27a/,但不知怎的,CanBeSeen是RoutedUICommand派生類的屬性的想法並不吸引我。
基於什麼控制可見性?關於命令的可執行性? –
基於我的自定義邏輯,它與命令可執行邏輯不同。 –