Win10的UWP之进度条
来源:互联网 发布:数据库系统工程师报名 编辑:程序博客网 时间:2024/05/16 05:48
关于UWP的进度条的处理的方案有两种方案
我们新建一个项目,然后处理的界面如下的代码
<Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <TextBlock Text="选择" FontSize="20" Grid.Row="0" HorizontalAlignment="Center"/> <RadioButton Content="Determinate类型" Height="71" Name="radionButton1" GroupName="Type" Grid.Row="1" HorizontalAlignment="Center"/> <RadioButton Content="Indeterminate类型" Height="71" Name="radioButton2" GroupName="Type" IsChecked="True" Grid.Row="2" HorizontalAlignment="Center"/> <Button Content="启动ProgressBar" Height="72" x:Name="Begin" Click="Begin_Click" Grid.Row="3" HorizontalAlignment="Center"/> <Button Content="取消ProgressBar" Height="72" x:Name="Cancel" Click="Cancel_Click" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"/> <ProgressBar x:Name="ProgressBar" IsIndeterminate="True" Grid.Row="5" Height="24"/>
然后我们再来处理下界面的后台代码
public MainPage() { this.InitializeComponent(); //初始化界面时,设置进度条不可见 ProgressBar.Visibility = Visibility.Collapsed; } private void Begin_Click(object sender, RoutedEventArgs e) { //启动进度条,并可以显示状态 ProgressBar.Visibility = Visibility.Visible; if (radionButton1.IsChecked==true) { //设置进度条的模式为不重复状态 ProgressBar.IsIndeterminate = false; //启用定时器,再每下一秒改变原来的状态 DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); } else { ProgressBar.Value = 0; ProgressBar.IsIndeterminate = true; } } async void timer_Tick(object sender,object e) { if (ProgressBar.Value<100) { ProgressBar.Value += 10; } else { (sender as DispatcherTimer).Tick -= timer_Tick; (sender as DispatcherTimer).Stop(); await new MessageDialog("进度100%").ShowAsync(); } } private void Cancel_Click(object sender, RoutedEventArgs e) { ProgressBar.Visibility = Visibility.Collapsed; }
我们来看一下运行的效果吧
这是模拟了手机的界面运行的结果
3 0
- Win10的UWP之进度条
- win10 uwp 异步进度条
- win10 uwp 进度条 Marquez
- win10 uwp 进度条 WaveProgressControl
- Win10的UWP开发之Hello World
- Win10之UWP的数据存储
- Win10的UWP之标题栏的返回键(二)
- Win10的UWP之标题栏的返回键(一)
- Win10开发之UWP控件的隐藏空间
- 【Win10】UAP/UWP/通用 开发之 SplitView
- win10 uwp 获取指定的文件 AQS
- UWP——HttpClient模拟浏览器的GET、POST请求之Win10 Mobile测试
- win10 UWP读写文件
- Win10/UWP开发-Ink
- win10 uwp 通知Toast
- win10 UWP 显示地图
- win10 uwp 参考
- win10 uwp clone
- LeetCode 371. Sum of Two Integers
- java基础Day02
- Java自带线程池
- 13.浮动:给子集加浮动父级的文字会被排挤出去;同样的效果兄弟集也一样试用!
- django学习之学前准备篇
- Win10的UWP之进度条
- opencv保存图片信息
- 【软件工程】滨江学院 李振宏 软件工程 考点整理
- 机房合作验收总结
- 设计模式-1、简单工厂模式
- Android 自定义View之消息提示控件
- 【机器学习入门】线性回归的概率解释
- CodeForces 580B Kefa and Company
- Spring主要核心