博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows phone之山寨win8圆形进度条
阅读量:5732 次
发布时间:2019-06-18

本文共 5733 字,大约阅读时间需要 19 分钟。

 
Visible
Visible
 

 

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;namespace Monsters.WindowsPhone.Controls{    public class ProgressRing : Control    {        bool hasAppliedTemplate = false;        public ProgressRing()        {            this.DefaultStyleKey = typeof(ProgressRing);            TemplateSettings = new TemplateSettingValues(60);        }        public override void OnApplyTemplate()        {            base.OnApplyTemplate();            hasAppliedTemplate = true;            UpdateState(this.IsActive);        }        void UpdateState(bool isActive)        {            if (hasAppliedTemplate)            {                string state = isActive ? "Active" : "Inactive";                System.Windows.VisualStateManager.GoToState(this, state, true);            }        }        protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)        {            var width = 100D;            if (!System.ComponentModel.DesignerProperties.IsInDesignTool)                width = this.Width != double.NaN ? this.Width : availableSize.Width;            TemplateSettings = new TemplateSettingValues(width);            return base.MeasureOverride(availableSize);        }        public bool IsActive        {            get { return (bool)GetValue(IsActiveProperty); }            set { SetValue(IsActiveProperty, value); }        }        // Using a DependencyProperty as the backing store for IsActive.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty IsActiveProperty =            DependencyProperty.Register("IsActive", typeof(bool), typeof(ProgressRing), new PropertyMetadata(false, new PropertyChangedCallback(IsActiveChanged)));        private static void IsActiveChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)        {            var pr = (ProgressRing)d;            var isActive = (bool)args.NewValue;            pr.UpdateState(isActive);        }        public TemplateSettingValues TemplateSettings        {            get { return (TemplateSettingValues)GetValue(TemplateSettingsProperty); }            set { SetValue(TemplateSettingsProperty, value); }        }        // Using a DependencyProperty as the backing store for TemplateSettings.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty TemplateSettingsProperty =            DependencyProperty.Register("TemplateSettings", typeof(TemplateSettingValues), typeof(ProgressRing), new PropertyMetadata(new TemplateSettingValues(100)));        public class TemplateSettingValues : System.Windows.DependencyObject        {            public TemplateSettingValues(double width)            {                MaxSideLength = 400;                EllipseDiameter = width / 10;                EllipseOffset = new System.Windows.Thickness(EllipseDiameter);            }            public double MaxSideLength            {                get { return (double)GetValue(MaxSideLengthProperty); }                set { SetValue(MaxSideLengthProperty, value); }            }            // Using a DependencyProperty as the backing store for MaxSideLength.  This enables animation, styling, binding, etc...            public static readonly DependencyProperty MaxSideLengthProperty =                DependencyProperty.Register("MaxSideLength", typeof(double), typeof(TemplateSettingValues), new PropertyMetadata(0D));            public double EllipseDiameter            {                get { return (double)GetValue(EllipseDiameterProperty); }                set { SetValue(EllipseDiameterProperty, value); }            }            // Using a DependencyProperty as the backing store for EllipseDiameter.  This enables animation, styling, binding, etc...            public static readonly DependencyProperty EllipseDiameterProperty =                DependencyProperty.Register("EllipseDiameter", typeof(double), typeof(TemplateSettingValues), new PropertyMetadata(0D));            public Thickness EllipseOffset            {                get { return (Thickness)GetValue(EllipseOffsetProperty); }                set { SetValue(EllipseOffsetProperty, value); }            }            // Using a DependencyProperty as the backing store for EllipseOffset.  This enables animation, styling, binding, etc...            public static readonly DependencyProperty EllipseOffsetProperty =                DependencyProperty.Register("EllipseOffset", typeof(Thickness), typeof(TemplateSettingValues), new PropertyMetadata(new Thickness()));        }    }}

样式:

Visible
Visible

  

支持wp7、wp8.。当然wp8.1 自带这个控件

 

 

转载于:https://www.cnblogs.com/walleyekneel/p/3624670.html

你可能感兴趣的文章
一点不懂到小白的linux系统运维经历分享
查看>>
MDT 2013 从入门到精通之软件自动化部署设置
查看>>
桌面支持--打不开网页上的pdf附件解决办法(ie-tools-compatibility)
查看>>
桌面支持--outlook取消收件规则1
查看>>
nagios监控windows 改了NSclient++默认端口 注意事项
查看>>
干货 | JAVA代码引起的NATIVE野指针问题(上)
查看>>
POI getDataFormat() 格式对照
查看>>
Project build error: Non-resolvable import POM
查看>>
Python 中的进程、线程、协程、同步、异步、回调
查看>>
swoft速学~redis引入
查看>>
LTS
查看>>
sublime插件自用
查看>>
Mysql客户端工具可以连接,但是代码访问就会报错
查看>>
Free Windows Applications
查看>>
好的产品原型具有哪些特点?
查看>>
实现java导出文件弹出下载框让用户选择路径
查看>>
刨根问底--技术--jsoup登陆网站
查看>>
awk学习笔记
查看>>
OSChina 五一劳动节乱弹 ——女孩子晚上不要出门,发生了这样的事情
查看>>
OSChina 周四乱弹 ——心有鱼,而力不足
查看>>