This project has moved and is read-only. For the latest updates, please go here.
3

Closed

RelayCommand Variable Scope Lost

description

int myNum = 1;
var command = new RelayCommand(() => { myNum = 2;}, () => myNum == 1);

In the code above a button is bound to the command. Before the latest update it would work but now it does not. When trying to put a break point in the canExecute, it is never even triggered when it should be.

Found a work around of making the variable myNum a field of the class. Could there be a scoping issue with local variables?
Closed Oct 13, 2014 at 1:58 PM by lbugnion

comments

lbugnion wrote Jul 27, 2012 at 11:33 AM

Hi,

Can you give me more information: Which framework are you using that on? (WPF, Silverlight, Windows Phone, Windows 8)?

Thanks,
Laurent

tweak206 wrote Jul 27, 2012 at 5:46 PM

Hi,
Of course. I am using the WPF framework.
Thanks,
Michael

dustinmccoy wrote Aug 17, 2012 at 3:42 PM

Same problem here, using WPF, .NET 4. I noticed a change in the WeakAction class but am unsure if that's where the problem was introduced.