maui icon indicating copy to clipboard operation
maui copied to clipboard

Button IsEnabled="{Binding IsBttEnabled}" - Not working - but IsVisible works

Open Proktologe opened this issue 3 years ago • 2 comments

Description

Hi, I m not able to change the IsEnabled State of my Button. But if i change it with IsVisible it all works.

My xaml Page:

<Button Command="{Binding BttWeiterCommand}" IsEnabled="{Binding IsBttWeiterEnabled}" Grid.Row="1" Grid.Column="1" HorizontalOptions="Center" Text="Weiter" WidthRequest="200"/> <Button Command="{Binding BttZureckCommand}" Grid.Row="1" Grid.Column="0" HorizontalOptions="Center" Text="Zureck" WidthRequest="200"/>

My ViewModel:

//[ObservableProperty]  //also not work with CommunityToolkit
public bool IsBttEnabled{ get; set; } = true;

[RelayCommand]
        async Task BttWeiter()
        {
            try
            {
                if(IndexSelectedItem < List_InfoBoxen.Count-1)
                    IndexSelectedItem++;

                if (List_InfoBoxen[IndexSelectedItem].IsSkipButtonVisible)
                    IsBttEnabled= false;
                else
                    IsBttEnabled= true;

                //...
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex);  
            }
            finally
            {
                   IsBttEnabled= false; //just for testing - NOT working for IsEnabled
            }
            
        }

        [RelayCommand]
        void BttZureck()
        {
            try
            {
                if (IndexSelectedItem > 0)
                    IndexSelectedItem--;

                if (List_InfoBoxen[IndexSelectedItem].IsSkipButtonVisible)
                    IsBttEnabled= false;
                else
                    IsBttEnabled= true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex);
            }
            IsBttEnabled= false; //just for testing - NOT working for IsEnabled
        }

Steps to Reproduce

  1. Add new MAUI Page

  2. add my code to the MAUI page

  3. add my button codes

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 10 Home, 19044.1889

Did you find any workaround?

No response

Relevant log output

No response

Proktologe avatar Aug 10 '22 20:08 Proktologe

Duplicate of https://github.com/dotnet/maui/issues/7377

IsEnabled is broken for Windows

MagicAndre1981 avatar Aug 10 '22 22:08 MagicAndre1981

oh man. thx for the info.

Proktologe avatar Aug 10 '22 22:08 Proktologe

Duplicate of #7377

jfversluis avatar Aug 11 '22 09:08 jfversluis