在 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
没有显示?我怎么能让它显示出来?
答案 0 :(得分:6)
据我了解,您告诉ActivityIndicator
展示自己,然后导航到另一个页面。并且新页面没有ActivityIndicator
。我建议您使用OnAppearing
BookPage
方法进行艰苦的操作。
protected override void OnAppearing()
{
base.OnAppearing();
activityIndicator.IsVisible = true;
// Some hard operations
activityIndicator.IsVisible = false;
}
或使用绑定代替activityIndicator.IsVisible = true;