在Xamarin.Forms项目上,我试图告诉ActivityIndicator
显示自己,然后导航到另一页
activityIndicatorObject = new ActivityIndicator()
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
Color = Color.Red,
IsVisible = false,
IsRunning = false,
IsEnabled = false,
BindingContext = this,
};
ViewBookButton = new Button{ Text = "view book" };
ViewBookButton.Clicked += ViewBook;
protected void ViewBook(Object sender,EventArgs e)
{
//Go To View Book Page
activityIndicatorObject .IsVisible = true;
activityIndicatorObject .IsRunning = true;
activityIndicatorObject .IsEnabled = true;
activityIndicatorObject .SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
this.IsBusy = true;
Navigation.PushAsync(new BookPage());
this.IsBusy = false;
}
ActivityIndicator
没有显示?如何使它显示? 最佳答案
据我了解,您告诉ActivityIndicator
显示自己,然后导航到另一页。并且新页面没有自己的ActivityIndicator
。我建议您使用OnAppearing
的BookPage
方法进行艰苦的操作。
protected override void OnAppearing()
{
base.OnAppearing();
activityIndicator.IsVisible = true;
// Some hard operations
activityIndicator.IsVisible = false;
}
或使用绑定代替
activityIndicator.IsVisible = true;
关于c# - 告诉ActivityIndicator展示自己,然后导航到另一页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35776012/