WPF编程,数据加载显示圆形加载进度条的一种方法

添加引用:Microsoft.Expression.Drawing.dll

下载地址:https://download.csdn.net/download/qq_43307934/10923136

适用于.NET 4.0

XAML增加命名空间:


xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" mc:Ignorable="d" 
 

 <Grid Width=" 150"
              Grid.Row=" 1"
              Height=" 150">

            <Ellipse Stroke="Gray"
                     StrokeThickness="3"
                     Opacity="0.6" />

            <ed:Arc ArcThickness="15"
                    EndAngle="180"
                    Margin="0"
                    Stretch="None"
                    Stroke="Transparent"
                    StrokeThickness="0"
                    StartAngle="0"
                    Fill="#FF0071BC"
                    x:Name="EllipseFill" />

            <TextBlock Foreground="Green"
                       FontSize="30"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="0,-40,0,0"
                       Text="0%"
                       x:Name="TValue"
                       FontFamily="Segoe UI" />
            <TextBlock Foreground="Red"
                       FontSize="17"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="0,0,0,-45"
                       x:Name="TText"
                       Text="加载中……"
                       FontFamily="Segoe UI Light" />
        </Grid>

后台部分代码:

        DispatcherTimer timer = new DispatcherTimer();
        private int angle = 0;
        public MainWindow()
        {
            InitializeComponent();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = TimeSpan.FromMilliseconds(1);
            timer.Start();
        }


        public   void timer_Tick(object sender, EventArgs e)
        {
            if (angle<360)
            {
                angle++;
                EllipseFill.EndAngle = angle;
            }
            else
            {
                angle = 0;
                EllipseFill.EndAngle = angle;

            }
        }

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值