Skip to content

Instantly share code, notes, and snippets.

@davamix
Created August 23, 2016 09:05
Show Gist options
  • Save davamix/77fa693ffe9f31111a909215e49a42e5 to your computer and use it in GitHub Desktop.
Save davamix/77fa693ffe9f31111a909215e49a42e5 to your computer and use it in GitHub Desktop.
<Button Content="Hello" Command="{Binding HelloCommand}"/> <!-- Works OK --> 
<Button Content="Hello" Command="{Binding HelloCompositeCommand}"/> <!-- Nope :( -->
public class MainWindowViewModel : BindableBase
    {
        public DelegateCommand HelloCommand { get; set; }
        public CompositeCommand HelloCompositeCommand { get; set; }
        
        public MainWindowViewModel()
        {
            HelloCommand = new DelegateCommand(SayHello, CanSayHello) {IsActive = true};

            HelloCompositeCommand = new CompositeCommand(true);
            HelloCompositeCommand.RegisteredCommands.Add(HelloCommand);
        }

        private bool CanSayHello()
        {
            return true;
        }

        private void SayHello()
        {
            Debug.WriteLine("Hi!");
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment