Problem
My StackLayout
is always visible. The isBusy
seems to work because my ActivityIndicator
is not running.
Version
I use Xamarin.Forms in xamarin.forms.4.6.0.494-pre2
. I need to run the pre release version due to the Surface Duo SDK which requires this kind of alpha Xamarin.Forms Version.
Code Base ViewModel
bool isBusy = false;
public bool IsBusy
{
get { return isBusy; }
set { SetProperty(ref isBusy, value); }
}
Code Page View Model
public void LoadData()
{
IsBusy = true;
LoadAsync();
IsBusy = false;
}
Code XAML
<StackLayout IsVisible="{Binding IsBusy}">
<!-- Animated spinner -->
<ActivityIndicator Color="{StaticResource PrimaryReduced}" IsRunning="{Binding IsBusy}" />
<!-- Text -->
<Label Text="Loading ..." />
</StackLayout>
Update: Other things I tried
I read a lot that this was a malfunction behavior in prior versions of Xamarin.Forms. That's why I tried to workaround this behavior by setting the opacity
value to 0 of my StackLayout
.
Opacity="{Binding Path=IsBusy, Converter={StaticResource BoolToLoadingViewOpacityValueConverter}}"
But this custom converter never gets called.
Update 2: Source code
IsBusy
flag now what I need to know are two simple things.IsBusy
properties location i.e. xaml.cs/viewmodel or whatever and the context in which this layout is i.e. under a listview or not or some other binding context If any!BindingContext
is not set or propagated down to all views/layouts/controls (please note that you have a custom view with aBindingContext
that might not be set). Some platforms might indicate not found properties in the debug output. The default value of properties might vary, but I think the default values are documented, at least for base classes (for example aStackLayout
is aLayout
whereIsVisible
by default is true).