I have absolutely no idea what's causing this.
Background: Using the Prism Framework
- I have a button bound to a
DelegateCommand
- I call
RaiseCanExecuteChanged
When I start the app in debugging mode in Visual Studio, everything works perfectly. The app runs perfectly.
When I then open the app via the .exe, the RaiseCanExecuteChanged
method is not being called. I have no idea why this would be the case. Anybody else run into a similar problem?
EDIT: When I first open the app via the .exe, RaiseCanExecuteChanged
is called (since I set it in the constructor of my ViewModel
). However, it is never called again.
Code in case it's needed:
private readonly DelegateCommand _buttonCommand;
public ViewModel()
{
_buttonCommand = new DelegateCommand(Button, CanExecuteButton);
}
public DelegateCommand ButtonCommand
{
get { return this._buttonCommand; }
}
public void Button()
{
... do stuff ...
_buttonCommand.RaiseCanExecuteChanged();
}
public bool CanExecuteButton()
{
if (some condition)
return true;
else
return false;
}
<Button x:Name="MyButton" Content="ClickMe"
Command="{Binding ButtonCommand}">
I even got desperate and tried putting an IsEnabled
property in my Button which I bound to CanExecuteButton
... to no avail.