Increase size of Dots in Progress bar windows phone 8

微笑、不失礼 提交于 2019-12-25 17:14:11

问题


I wanted to display Progress bar Ellipse more that its Default size like this : increase height of indeterminate progress dot size.

I have gone through goggling and many Questions and Post of blogs but could not find any Solution

Already seen this also but not working in my case:

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

回答1:


If you don't mind a few Overrides :)

I've heavily modified most of the common controls to get the look I'm after with a little XAML as possible. Here's a cut and paste from a earlier progress bar I was using to meet what you want to do.

XAML Namespace


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



C# Progress Bar Override


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;
        }
    }
}



How To Use


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

Progress Bar In Action



来源:https://stackoverflow.com/questions/25459402/increase-size-of-dots-in-progress-bar-windows-phone-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!