I use your ribbon buttons to perform several actions, all of which are bound using the buttons Command parameter to a DelegateCommand property in my ViewModel. Application logic may enable and disable the canExecute parameter of the DelegateCommand, but the button enable state does not change. I am also firing a PropertyChanged event whenever enable/disable logic changes occur so they can propogate to the View, but this has no effect.
If I hide and then show the ribbion bar, I found that the changes were pushed out to the view properly. Why doesn't onPropertyChange events modify the enable state of the ribbon:button automatically?
At one point in the project, we were using the application button, and everything worked fine (or so I thought). It seems that what was really happening, is that when the app button was clicked on, then the underlying button states were updated.
<ribbon:Button x:Name="saveTestButton" Label="Save Test" KeyTipAccessText="S" Command="{Binding Path=SaveTest}"/>
private DelegateCommand saveTest;
private bool saveTestEnabled = false;
...
public DelegateCommand SaveTest
{
get
{
return saveTest;
}
set
{
saveTest = value;
onPropertyChanged("SaveTest");
}
}
...
saveTest = new DelegateCommand(SaveTestAction, canSaveTestAction);
private bool canSaveTestAction()
{
return saveTestEnabled;
}
private void SaveTestAction()
{
//Save test stuff...
}
private void onPropertyChanged(string propertyChanged)
{
if (PropertyChanged != null)
{
PropertyChanged(this,new PropertyChangedEventArgs(propertyChanged));
}
}