I am not sure if this is an MVVM-Light bug or just something that doesn't work in WPF.... I have a button where I am setting the Command property to a RelayCommand. Everything works fine as long as I don't set the CommandParameter property. Once I do, the CanExecute callback quits working.
I am using the GalaSoft.MvvmLight.CommandWpf namespace as I am working in .Net 4.5.2. Here is a code snippit:
public RelayCommand<IList> SetFlagCommand { get; private set; }
...
SetFlagCommand = new RelayCommand<IList>(SetFlag, CanSetFlag);
...
mButtons.Add(new Button
{
...
Command = SetFlagCommand,
CommandParameter = new Binding("SelectedItems") { ElementName = "lstAllChoices" },
});
...
private void SetFlag(IList list)...
private bool CanSetFlag(IList list)...
The CanSetFlag method is called once, but then never again. If I don't set the CommandParameter property, it works as expected. Any ideas what is going on?
Thanks for any help!