【问题标题】:Increase size of Dots in Progress bar windows phone 8增加进度条中点的大小 windows phone 8
【发布时间】:2014-08-23 07:10:31
【问题描述】:

我想显示进度条椭圆,而不是像这样的默认大小:increase height of indeterminate progress dot size

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

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

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

【问题讨论】:

  • 为什么这些链接对你不起作用?
  • 我已尝试链接第一个链接 xmlns:unsupported="clr-namespace:Microsoft.Phone.Controls.Unsupported" 具有旧版本的 silverlight 工具包,因此它在我的项目中不起作用,给我错误和第二个代码正在工作,但效果不佳,因为它没有显示所有进度指示器。它只显示一个没有移动的矩形

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


【解决方案1】:

如果你不介意一些覆盖:)

我已经对大多数常用控件进行了大量修改,以尽可能使用一点 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>

进度条在行动

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多