Fix*_*xus 1 xaml microsoft-metro windows-runtime winrt-xaml windows-store-apps
我的应用程序中有许多媒体元素通过Web流式传输.有时候我需要等2-3秒才能完成.这对我来说不是问题.问题是我不知道如何制作某种加载动画.我有一个加载栏的动画GIF,但我不知道如何显示它.有任何想法吗 ?
你不需要它的GIF.有一个XAML Control 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;
}
}
Run Code Online (Sandbox Code Playgroud)
对于XAML,例如:
<ProgressRing IsActive="{Binding IsLoading}"
DataContext="{Binding MyDataService}"
Width="50"
Height="50" />
Run Code Online (Sandbox Code Playgroud)
由于绑定(以及来自标准MS模板的BindableBase(否则您需要实现INotifyPropertyChanged))当您的数据服务正在执行某些操作时,ProgressRing将自动激活.