Forum Xamarin.iOS

ActivityIndacor in a Thread

kaanakyalcin.2185kaanakyalcin.2185 USMember ✭✭
edited January 2017 in Xamarin.iOS

Hi guys,

I try to get some datas from a webservice when page is opening.
Also try to show an activity indactor when thread works.

But i could'nt find any sample for this.

Could you help me about sample or code:)

Answers

  • KolaMounikaKolaMounika USMember ✭✭✭

    @kaanakyalcin.2185

    Try to create a IsBusy property in your ViewModel

       private bool _isBusy;
       public bool IsBusy
       {
          get { return _isBusy; }
          set
          {
              _isBusy = value;
              OnPropertyChanged();
           }
       }
    

    and bind IsBusy to ActivityIndicator in XAML

     <ActivityIndicator
                           IsVisible="{Binding IsBusy}"
                           IsRunning="{Binding IsBusy}"/>
    

    in the thread that your are trying to get data from web service set IsBusy like below

     try
     {
          IsBusy = true;
          //Your code to get data 
     }
     catch (Exception exception)
     {
     }
     finally
     {
           IsBusy = false;
     }
    
Sign In or Register to comment.