增加Dots in Progress bar windows phone 8的大小

时间:2014-08-23 07:10:31

标签: c# xaml windows-phone-8 windows-phone progress-bar

我想显示进度条椭圆,其默认大小如下:increase height of indeterminate progress dot size

我已经经历了许多问题和帖子的博客,但找不到任何解决方案

已经看到了这一点,但在我的情况下不起作用:

  1. The high performance ProgressBar for Windows Phone (“PerformanceProgressBar”)
  2. A thicker ProgressBar in WP7, how?

1 个答案:

答案 0 :(得分:2)

如果你不介意几个覆盖:)

我已经对大多数常用控件进行了大量修改,以便在看到尽可能少的XAML后再看看。这是我用来满足你想要做的早期进度条的剪切和粘贴。

XAML命名空间


<phone:PhoneApplicationPage
 xmlns:MyControl="clr-namespace:MyOverrideConrols"    
>



C#进度条覆盖


namespace MyOverrideConrols
{
    public class MyProgressBar : ProgressBar
    {
        public MyProgressBar()
            : base()
        {
            this.NewDotSize = 20;
        }
        public MyProgressBar(int dot_size = 20)
            : base()
        {

            this.NewDotSize = (dot_size <= 0) ? 1 : dot_size;
        }

        public int NewDotSize{ get; set; }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Rectangle slider_0 = (Rectangle)this.GetTemplateChild("Slider0"); ResizeRectangle(ref slider_0, NewDotSize);
            Rectangle slider_1 = (Rectangle)this.GetTemplateChild("Slider1"); ResizeRectangle(ref slider_1, NewDotSize);
            Rectangle slider_2 = (Rectangle)this.GetTemplateChild("Slider2"); ResizeRectangle(ref slider_2, NewDotSize);
            Rectangle slider_3 = (Rectangle)this.GetTemplateChild("Slider3"); ResizeRectangle(ref slider_3, NewDotSize);
            Rectangle slider_4 = (Rectangle)this.GetTemplateChild("Slider4"); ResizeRectangle(ref slider_4, NewDotSize);
            Rectangle slider_5 = (Rectangle)this.GetTemplateChild("Slider5"); ResizeRectangle(ref slider_5, NewDotSize);

        }

        private void ResizeRectangle(ref Rectangle rect, int new_size)
        {
            if (rect == null)
                return;
            rect.Width = new_size;
            rect.Height = new_size;
        }
    }
}



如何使用


<MyControl:MyProgressBar IsIndeterminate="True" Height="25" NewDotSize="20"></MyControl:MyProgressBar>

进度条在行动

enter image description here