I am trying to Bind Button state and Command Action to a ViewModel associated with a document window. When the active Document changes I set the DataContext of the desired Group, which then progates to it's buttons. The command bound in the XAML executes correctly, but the Button appears to only read the Enabled Property state; however, clicking the button does not invoke the setter on the viewmodel property. How can this be accomplished?
<ribbon:Group Label="Component" x:Name="componentGroup">
<ribbon:Button Command="{Binding TestCommand}"
ImageSourceSmall="pack://application:,,,/ActiproSoftware.Ribbon.Wpf30;component/ Products/Ribbon/Images/ButtonDefault32.png" Label="New Button" />
<ribbon:Button IsChecked="{Binding Enabled}"
ImageSourceSmall="pack://application:,,,/ActiproSoftware.Ribbon.Wpf30;component/ Products/Ribbon/Images/ButtonDefault32.png" Label="New Button" />
I set the Group DataContext when a Document becomes active
componentGroup.DataContext = _control.ViewModel;
My ViewModel (implements INotifyPropertyChanged) has the following Property and DelegateCommand
private bool _Enabled;
public bool Enabled
{
get { return this._Enabled; }
set
{
if (this._Enabled == value)
return;
this._Enabled = value;
OnPropertyChanged(() => Enabled);
}
}
DelegateCommand _TestCommand;
public DelegateCommand TestCommand
{
get
{
if (_TestCommand == null)
_TestCommand = new DelegateCommand(Test, CanTest);
return _TestCommand;
}
}
public bool CanTest()
{
return _canTestIt;
}
public void Test()
{
}
<ribbon:Group Label="Component" x:Name="componentGroup">
<ribbon:Button Command="{Binding TestCommand}"
ImageSourceSmall="pack://application:,,,/ActiproSoftware.Ribbon.Wpf30;component/ Products/Ribbon/Images/ButtonDefault32.png" Label="New Button" />
<ribbon:Button IsChecked="{Binding Enabled}"
ImageSourceSmall="pack://application:,,,/ActiproSoftware.Ribbon.Wpf30;component/ Products/Ribbon/Images/ButtonDefault32.png" Label="New Button" />
I set the Group DataContext when a Document becomes active
componentGroup.DataContext = _control.ViewModel;
My ViewModel (implements INotifyPropertyChanged) has the following Property and DelegateCommand
private bool _Enabled;
public bool Enabled
{
get { return this._Enabled; }
set
{
if (this._Enabled == value)
return;
this._Enabled = value;
OnPropertyChanged(() => Enabled);
}
}
DelegateCommand _TestCommand;
public DelegateCommand TestCommand
{
get
{
if (_TestCommand == null)
_TestCommand = new DelegateCommand(Test, CanTest);
return _TestCommand;
}
}
public bool CanTest()
{
return _canTestIt;
}
public void Test()
{
}