How to visible indicator on busy

Am trying to do the front end XAML code in C#. When I try to bind the activity indicator with IsBusy Am not able to achieve it.

I want the activity indicator to pop up when the page is busy.

1 answer

  • answered 2018-05-16 12:56 Mohammed Ameen

    This post is to Show How can we achieve a basic screen with scrollview and a indicator in backend C# code.

    the Layout assigned to the scroll Content is any basic layout which we design as per the requirement.

    Here is my code sample:

    #region render
    scroll = new ScrollView
    {
        Content = layout
    };
    AbsoluteLayout.SetLayoutBounds(scroll, new Rectangle(0, 0, 1, 1));
    AbsoluteLayout.SetLayoutFlags(scroll, AbsoluteLayoutFlags.All);
    
    AbsoluteLayout screenMask = new AbsoluteLayout { BackgroundColor = Color.FromHex("#22000000") };
    screenMask.BindingContext = this;
    screenMask.SetBinding(IsVisibleProperty, "IsBusy", BindingMode.OneWay);
    AbsoluteLayout.SetLayoutBounds(screenMask, new Rectangle(0.5, 0.5, 1, 1));
    AbsoluteLayout.SetLayoutFlags(screenMask, AbsoluteLayoutFlags.All);
    
    ActivityIndicator indicator = new ActivityIndicator { Color = Color.Black };
    indicator.BindingContext = this;
    indicator.SetBinding(IsVisibleProperty, "IsBusy",BindingMode.OneWay);
    indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
    AbsoluteLayout.SetLayoutBounds(indicator, new Rectangle(0.5, 0.5, 0.1, 0.1));
    AbsoluteLayout.SetLayoutFlags(indicator, AbsoluteLayoutFlags.All);
    
    Content = new AbsoluteLayout
    {
        Children = { scroll, screenMask, indicator }
    };
    #endregion
    

    Hope this helps many people.