ProgressBar 自我学习笔记(二)
1.自定义弹出加载效果:
调用PopupContainer弹窗口,加载内容是自定义控件LoadingControl
LoadingControl load = new LoadingControl(); PopupCotainer input = new PopupCotainer(this); input.Show(load);
这样,当网络请求时加载进度条显示,网络加载完成时,调用
this.load.CloseMeAsPopup();
关闭加载自定义页面;
2.上面的方法完全可行,而且自定义幅度很大,很方便,唯一不足就是,会覆盖下面页面,只能显示当前加载进度条页面,我尝试设置Opacity来设置透明度,发现无用,如果想要蒙层的效果,代码如下:
XAML代码: xmlns:Fun="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls" xmlns:tookit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:Converters="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls" 控件代码: <Fun:ProgressOverlay Name="progressOverlay" Visibility="{Binding OverlayVis}"> <Fun:ProgressOverlay.Resources> <Converters:VisibilityToBooleanConverter x:Key="VisToBoolConverter" /> </Fun:ProgressOverlay.Resources> <StackPanel> <TextBlock HorizontalAlignment="Center">Loading</TextBlock> <tookit:PerformanceProgressBar IsIndeterminate="{Binding ElementName=progressOverlay, Path=Visibility, Converter={StaticResource VisToBoolConverter}}" /> </StackPanel> </Fun:ProgressOverlay>
当然上面这段代码非本人原创。这样在后台控制显示和隐藏就可以达到蒙层效果,自我感觉不错哦!