1
votes

I tried searching for the same error with no results so here's my question:

I have a Xamarin form project that will be deployed on Android and iOS. In one of my views i have 2 buttons that will only be visible if the user has selected a few option first. This is working just fine on iOS, but when I deploy on the Android simulator the buttons are not being displayed unless I switch orientations. Here's a sample of the code:

<Button
    Grid.Column="0"
    Grid.Row="0"
    TextColor="{StaticResource AwesomeTxtColor}"
    Text="Click Me"
    BackgroundColor="{StaticResource AwesomeBgColor}"
    IsVisible="{Binding SelectedIndex, Converter={StaticResource isGreaterOrEqualZero}}"
    Command="{Binding AwesomeCommand}" />

Again, converter is working per debugging session and bindings too. The issue is only happening for me on Android. iOS is working as expected. Xamarin Forms version: 2.3.4.267. Anyone have experienced this before or have any ideas on what might be the problem?

1
It may be an layout issue. When the view doesn't fit in the container, android omits that view. This Grid (wich is the button container) have width and height definitions setted as Auto?Diego Rafael Souza
Hm that make sense. I will get back to you on the height. I believe it is Auto. Thanks a lot.Ph0b0x
Okay. Let me know if it doesn't work.Diego Rafael Souza
Alright so it was set to "*", i changed it to 75 just for testing still same results. Buttons are not being displayed unless i switch orientations :/Ph0b0x
Same behavior with "Auto". Buttons did not appear.Ph0b0x

1 Answers

1
votes

It turned out that it was a threading issue. Lists used to populate pickers on my view were loaded using:

await Task.Run(() => {
  //API calls to load lists
});

I changed that to:

Device.BeginInvokeOnMainThread(() => {
  //API calls to load lists
});

And now Android updates the UI. Odd but apparently those values on the lists were stuck on a different thread...