我的应用程序中有很多媒体元素都是通过web流传输的。有时我需要等待2-3秒。这对我来说不是问题。问题是我不知道如何制作加载的动画。我有一个装载栏的动画gif,但我不知道如何显示它。有什么想法吗?
发布于 2012-10-06 21:03:09
你不需要一个gif就可以了。有一个XAML控件ProgressRing。将它的IsActive属性绑定到一个指示您正在加载的属性。
类似于:
public class DataService : BindableBase
{
private bool _isLoading;
public bool IsLoading
{
get
{
return _isLoading;
}
set
{
SetProperty(ref _isLoading, "IsLoading");
}
}
public void MyMethodWhichTakesLongTime()
{
IsLoading = true;
// Do some time consumption
IsLoading = false;
}
}对于XAML,类似于:
<ProgressRing IsActive="{Binding IsLoading}"
DataContext="{Binding MyDataService}"
Width="50"
Height="50" />多亏了绑定(以及来自标准MS模板的BindableBase (否则您需要实现INotifyPropertyChanged)),当您的数据服务正在执行某些操作时,ProgressRing将自动激活。
发布于 2012-10-06 21:46:05
ProgressBar也是可用的,它是类似于Windows phone7的水平加载条
对于不确定的进度条,可以使用
<ProgressBar Visibility="Visible" IsIndeterminate="True" />https://stackoverflow.com/questions/12759716
复制相似问题