views:

23

answers:

1

Hi,

I'm doing a Microsoft Surface Application and I have this problem:

I use the MVVM-pattern. When a user places his ID-Card (with a tag on it) on the surface, this user is set as "current user". When pressing a button the user can edit his adress and other stuff. He is shown a "save"-button and an "exit"-button then. On these buttons there are RelayCommands to save the changes in the database or to discard the changes. So, when these buttons are shown first, they are inactive and you cannot click them because the "current user" that is the CommandParameter for the button-commands is still null at this time. A moment later when the Application recognizes that the "current user" is not null anymore, the button stays inactive but when you leave the application for a moment and return to it (like with using the microsoft-button on the keyboard) you can see that the button is active then. So I think I need a possibility to "refresh" the UserControls.

How can I do it?

+1  A: 

I think that you should force the evaluation of "CanExecute" on the Commands when the "Current user" change value (usually on setter). Depends on your implementantion of the ICommand you should have a method or an event to ask to re-evaluate the CanExecute status.

HTH

ema
yes it should be something similar to; e.CanExecute = CurrentUser != null;
Faisal
Seems to work. Thanks!
sofri