Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms buttons become disabled after touched

I use Xamarin.Forms and MvvmCross, but I've encountered a problem in applications. Buttons become disabled sometimes after touched and running the commands.

I added IsEnabled="True" to button but nothing changed

<Button 
    WidthRequest="36" 
    HeightRequest="36" 
    CornerRadius="18" 
    BorderWidth="2" 
    FontSize="18" 
    Text="{Binding OptionText}" 
    Command="{Binding OptionSelectedCommand}" 
    CommandParameter="{Binding .}" 
    IsEnabled="True" 
    VerticalOptions="Center" 
    HorizontalOptions="Center"/>

I want this button to be enabled always.

My Command code is:

new MvxAsyncCommand(async () => 
{ 
    if (option.IsSelected) 
    { 
        option.IsSelected = false; 
    } 
    else 
    { 
        option.OptionGroup.Options.ForEach(c => c.IsSelected = false);
        option.IsSelected = true; 
    } 

    return Task.CompletedTask; 
})
like image 836
Mehmet Avatar asked Jan 03 '19 07:01

Mehmet


1 Answers

Finally I found a solution about this problem. Problem is related to MvxAsyncCommand, solved by using Command instead of MvxAsyncCommand.

I think MvvmCross MvxAsyncCommand has a bug about running asynchronous methods

like image 114
Mehmet Avatar answered Nov 17 '22 10:11

Mehmet