You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you aware you can get the desired behaviour by using a 'CanExecute' Func/method for your MvxAsyncCommand, and not binding to the Enabled property?
So something like this...
private MvxAsyncCommand clickCommand;
public MvxAsyncCommand ClickCommand
{
get
{
clickCommand = clickCommand ?? new MvxAsyncCommand(ClickCommandExecute, ClickCommandCanExecute);
return clickCommand;
}
}
private async Task ClickCommandExecute()
{
EnableButton = !EnableButton;
await Task.CompletedTask;
}
private bool ClickCommandCanExecute()
{
return EnableButton;
}
private bool enableBtn;
public bool EnableBtn
{
get => enableBtn;
set
{
if (SetProperty(ref enableBtn, value))
{
ClickCommand.RaiseCanExecuteChanged();
}
}
}
Are you aware you can get the desired behaviour by using a 'CanExecute' Func/method for your MvxAsyncCommand, and not binding to the Enabled property?
So something like this...
private MvxAsyncCommand clickCommand;
public MvxAsyncCommand ClickCommand
{
get
{
clickCommand = clickCommand ?? new MvxAsyncCommand(ClickCommandExecute, ClickCommandCanExecute);
return clickCommand;
}
}
private async Task ClickCommandExecute()
{
EnableButton = !EnableButton;
await Task.CompletedTask;
}
private bool ClickCommandCanExecute()
{
return EnableButton;
}
private bool enableBtn;
public bool EnableBtn
{
get => enableBtn;
set
{
if (SetProperty(ref enableBtn, value))
{
ClickCommand.RaiseCanExecuteChanged();
}
}
}
Thanks for your idea. @elstringo
But I'm considering using Enable because of I also want the button change the color following enable change.
🐛 Bug Report
Xamarin.Android Cannot disable a button by binding "Enabled" which has binding "Click"
Expected behavior
Button can be disabled by binding "Enabled" in .axml code, not depends or relate to "Click" event of "Click" Binding
Reproduction steps
Configuration
Version: 7.x
Platform:
Some code:
private async Task ClickEvent()
{
this.EnableBtn = !this.EnableBtn;
}
The text was updated successfully, but these errors were encountered: