欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當前位置:主頁 > 軟件編程 > C#教程 >

WPF ProgressBar實現(xiàn)實時進度效果

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊: 次

本文實例為大家分享了WPF ProgressBar實現(xiàn)實時進度的具體代碼,供大家參考,具體內(nèi)容如下

簡單測試,頁面如圖:

利用上班的一點點空閑時間,做了個wpf progressbar的例子,覺得有潛力可挖,故放上來供大家參考,有寫的更好的請留言哦,方便交流學習,謝謝

這個xaml:

<Page x:Class="WpfBrowserAppDrill.ProgressBarPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  mc:Ignorable="d" 
Title="ProgressBarPage" Loaded="Page_Loaded">


 <Grid>
  <Button Margin="10" Click="Button_Click" VerticalAlignment="Top" Height="23" Width="100">進度條控制</Button>
  <TextBlock Name="txtJD" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="50">當前進度:</TextBlock>
  <ProgressBar Height="20" HorizontalAlignment="Center" Margin="8,167,0,0" 
Name="pb_import" VerticalAlignment="Top" Width="500" />
 </Grid>
</Page>

后臺代碼:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;


namespace WpfBrowserAppDrill
{
 /// <summary>
 /// ProgressBarPage.xaml 的交互邏輯
 /// </summary>
 public partial class ProgressBarPage : Page
 {


  public ProgressBarPage()
  {
   InitializeComponent(); 
  } 


  private void beginImport() 
  {
   double value = 0;
   double total = 100d;//得到循環(huán)次數(shù)
   while (value < total)
   {
    double jd = Math.Round(((value + 1) * (pb_import.Maximum / total)), 4);


    pb_import.Dispatcher.Invoke(new Action<System.Windows.DependencyProperty, object>(pb_import.SetValue),
     System.Windows.Threading.DispatcherPriority.Background,
     ProgressBar.ValueProperty,
     jd);
    //這里是加數(shù)據(jù)或費時的操作,我這里讓它掛起300毫秒
    Thread.Sleep(300);
    txtJD.Text = "當前的進度是:" + (value + 1) + "(實際值)" + jd + "(百分比)";
    value++;
   }
  }
  private void Button_Click(object sender, RoutedEventArgs e)
  {
   beginImport();
   ////new Thread(new ThreadStart(beginImport)).Start();


  }


  private void Page_Loaded(object sender, RoutedEventArgs e)
  {  
   pb_import.Maximum = 100;
   pb_import.Value = 0; 


  } 


 }
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持我們。

上一篇:string與stringbuilder兩者的區(qū)別

欄    目:C#教程

下一篇:c#獲取兩個特定字符之間的內(nèi)容并輸出的方法

本文標題:WPF ProgressBar實現(xiàn)實時進度效果

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/4958.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有