Need to display loading symbol while loading data from api upon button click.
That depends a lot on your page setup. The most straightforward way is to have a property called IsBusy in your viewmodel, then have an ActivityIndicator in your content somewhere with IsVisible, and IsRunning bound to IsBusy. Whenever you make a heavy call, set IsBusy = true, fire a PropertyChangedEvent to notify the view, and then set it back to false when you're done. You'd need to disable your controls whenever you do to make sure users aren't mashing buttons in the meantime (and that will be specific to what controls are on the page).
Thanks a lot for replying.
My code looks like this
public async void OnLoginButtonClicked(object sender, EventArgs e)
indicator.isrunning=true;// my activity indicator
Myfunction();//This api calls function
Right now while the function is getting loaded I need to show activity indicator.
Can you please your solution with this code as I am new to Xamarin forms.Thank you.
I have same Problem like you. If you found any solutions then please help me.
Thanks in advance
In the code above, Myfunction() is operating on the UI thread, so the ActivityIndicator cannot update as it needs the UI thread free. Have Myfunction() start a new task and do the work (not anything that touches the UI) in that task, making Myfunction() async and then having the code above await Myfunction().
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies