Enabling and disabling AppBarButton from ViewModel

Topics: Actions & Coroutines
Jan 20, 2012 at 4:07 AM
Edited Jan 20, 2012 at 4:22 AM

First, I want to thank the authors for this tremendous piece of work.  Does really simply development and also teaches one best practices.

Question is:

I have a ViewModel with methods Start() and CanStart().  I have defined an AppBarButton and set its x:Name to Start.  Button cals Start() when clicked and CanStart() is also getting called.  However, AppBarButton does not get disabled or enabled based on result from CanStart.  It always stays enabled.  Did I miss something trivial?

Just to Add, I am also calling PropertyChangedBase.Refresh but does not look like CanStart() gets called.


Jan 20, 2012 at 1:51 PM

Got property change notification to work, you must make CanStart a property rather than a method. My guess is that that is your problem in this case. Give that a try and let me know if it gets things working.

Jan 20, 2012 at 2:40 PM
Edited Jan 20, 2012 at 2:50 PM

That was it.  Thanks again. 

Does this convention also apply to the ApplicationBarMenuItems?   Setting x;Name on these to Start does not invoke Start() method in ViewModel when menu item is clicked. 

Jan 20, 2012 at 2:55 PM

Never mind for ApplicationBarMenuItem.  Needed to use your AppBarMenuItem instead.  Great stuff.