WPF Prism's delegatecommand not refreshing
Posted
by
gkar
on Stack Overflow
See other posts from Stack Overflow
or by gkar
Published on 2012-09-14T21:37:05Z
Indexed on
2012/09/14
21:37 UTC
Read the original article
Hit count: 216
I am building wpf edit form, that has two buttons, BeginEdit and Save And the form is bound to ViewModel that inherits from Prism's NotificationObject. There is a property called IsReadOnly And there are two commands that are Prism's DelegateCommands BeginEdit command and save command The code is here
private DelegateCommand _beginEdit;
public DelegateCommand BeginEdit
{
get
{
return _beginEdit ?? (_beginEdit = new DelegateCommand(() => this.IsReadOnly = false
, () => IsReadOnly));
}
}
private bool _isReadOnly; public bool IsReadOnly { get { return _isReadOnly; } set { _isReadOnly = value; RaisePropertyChanged("IsReadOnly"); } }
private DelegateCommand _saveEdit;
public DelegateCommand SaveEdit
{
get
{
return _saveEdit ?? (_saveEdit = new DelegateCommand(() => this.IsReadOnly = true
, () => !IsReadOnly));
}
}
So, as you see, the command will set IsReadOnly property to true or false, and CanExecute should get its value from the same property as well.
It works when I start the form. But after I press BeginEdit, the buttons stays as the same, and the canExecute is not reflecting the new value of IsReadOnly
© Stack Overflow or respective owner