我有一个带有此进度条的 mainpage.xaml:
<ProgressBar x:Name="DataLoading" Height="10" Margin="0,-14,0,0" Grid.Row="1" VerticalAlignment="Top" IsIndeterminate="True"/>
现在我需要在调用 web 服务后让这个进度条的可见性崩溃?我要去哪里拿?请帮助我对 mvvm 和 windowsphone 开发非常陌生?请告诉我你还需要什么代码才能给我答案谢谢 1
我有一个带有此进度条的 mainpage.xaml:
<ProgressBar x:Name="DataLoading" Height="10" Margin="0,-14,0,0" Grid.Row="1" VerticalAlignment="Top" IsIndeterminate="True"/>
现在我需要在调用 web 服务后让这个进度条的可见性崩溃?我要去哪里拿?请帮助我对 mvvm 和 windowsphone 开发非常陌生?请告诉我你还需要什么代码才能给我答案谢谢 1
只需将 bool 属性添加IsDataLoading到您的 ViewModel。使用BooleanToVisibiltyConverter将其值绑定到您的Visibilty属性。根据您的 Web 服务状态将该属性设置为 true 和 false。ProgressBarIsDataLoading
<Grid>
<Grid.Resources>
<BooleanToVisibiltyConverter x:Key="bool2VisConverter" />
</Grid.Resources>
<ProgressBar Visibility="{Binding IsDataLoading, Converter={StaticResource bool2VisConverter}}" />
</Grid>
在您的视图模型中:
private bool _isBusy;
public bool IsBusy
{
get
{
return _isBusy;
}
set
{
if (value == _isBusy)
return;
_isBusy = value;
DispatcherService.BeginInvoke(() =>
{
RaisePropertyChanged(() => IsBusy);
});
}
}
视图中的进度条:
<ProgressBar IsIndeterminate="True" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}}" />