我是Xamarin的初学者并且有问题。我必须从微调器进度条更改为常规进度条,例如this
我在MainPage.xaml中有这个故事板
<Storyboard x:Name="SpinnerStoryboard">
<DoubleAnimation FillBehavior="HoldEnd"
RepeatBehavior="Forever"
Storyboard.TargetName="SpinnerTransform"
Storyboard.TargetProperty="Angle"
From="0"
To="360"
Duration="00:00:00.5" />
</Storyboard>
同样在MainPage.xaml.cs中:
private void RefreshableScrollableContentPresenter_OnPullProgressChanged(object sender, RefreshProgressEventArgs e)
{
if (e.IsRefreshable)
{
if (e.PullProgress == 1)
{
// Progress = 1.0 means that the refresh has been triggered.
if (SpinnerStoryboard.GetCurrentState() == ClockState.Stopped)
SpinnerStoryboard.Begin();
}
else if (SpinnerStoryboard.GetCurrentState() != ClockState.Stopped)
SpinnerStoryboard.Stop();
else
{
// Turn the indicator by an amount proportional to the pull progress.
SpinnerTransform.Angle = e.PullProgress * 360;
}
}
}
和
private void RefreshableScrollableContentPresenter_OnRefreshRequested(object sender, RefreshRequestedEventArgs e)
{
var presenter = sender as RefreshableScrollableContentPresenter;
if (presenter != null)
{
using (var deferral = presenter.AutoRefresh ? e.GetDeferral() : null)
{
mainPageViewModel.ProductsViewModel.GetProductsCommand.Execute();
if (SpinnerStoryboard.GetCurrentState() != ClockState.Stopped)
SpinnerStoryboard.Stop();
}
}
}