I have a button bound to a ICommand
<Button Content="Remove" Command="{Binding RemoveCommand}" x:Name="btnRemove" Visibility="Collapsed" />
After some tasks is done, I made the button visible, except that they look disabled until I click something, why is that? The RemoveCommand looks like below
public ICommand RemoveCommand
{
get
{
if (_removeCommand == null)
{
_removeCommand = new RelayCommand(() =>
{
if (RemoveRequested != null)
RemoveRequested(this, EventArgs.Empty);
}, () =>
{
// CanExecute Callback
if (Status == WorkStatus.Processing || Status == WorkStatus.Pending)
{
Debug.WriteLine("Returning False" + Status); return false;
}
Debug.WriteLine("Returning True"); return true; // After uploads, this returns True, in my Output Window.
});
}
return _removeCommand;
}
after uploads, the CanExecute callback returns True, so button should be enabled, but it looks disabled till I click something, why is this happening?
Video of the Problem

Try CommandManager.InvalidateRequerySuggested().
This method should call the CanExecute() on the commands and that should update the IsEnabled of your buttons.
See http://msdn.microsoft.com/en-us/library/system.windows.input.commandmanager.invalidaterequerysuggested.aspx for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With