Tuesday, 15 May 2012

windows - WPF/XAML ProgressBar is not showing 100% width -


I have a question about the XAML code of progress bar. I have the following XAML code to display the bar:

    

The control to display the bar is:

   & Lt; Setter Property = "foreground" value = "{static resource source progression}" /> & Lt; Setter Property = "Borderbrush" value = "{Static Resource Color Progress Bag Field}" /> & Lt; Setter property = "height" value = "12" /> & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type progress bar}" & gt; & Lt; Grid name = "TemplateLetter" snappot devise pixel = "true" & gt; & Lt; Fill Rectangle = "{TemplateBinding Background}" RadiusX = "4" RadiusY = "4" /> & Lt; Border Background = "{Static Resource Color Progress Bag Field}" margin = "1" cornerRadia = "2" /> & Lt; Decorator name = "PART_Indicator" horizontal align = "left" & gt; & Lt; Grid name = "foreground" & gt; & Lt; Grid name = "animation" clipTobodes = "True" & gt; & Lt; Segment name = "PART_GlowRect" Width = "{TemplateBinding Value}" Segment Area = "0" CornerRadis = "4" Margin = "0,0,0,0" Horizontal Alignment = "Left" Background = "{Static Rhesus Color Progressiveness} "/> & Lt; / Grid & gt; & Lt; / Grid & gt; & Lt; / Decorator & gt; & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; Now, the problem is that the time is 100% width, but the active bar (value-variable in progress bar code) is not 80 percent, but 80 pixels (either). I can not give a hardcode width to the gray bar How can I make sure that the active bar (payeur) is showing correctly in percent?  

Thank you in advance!

Looking at the code for control it seems that this 'Part_ indicator' width is automatically set Handles it.

Reflected

  Public override zero OnApplyTemplate () {base.OnApplyTemplate (); If (this._track! = Null) {this._track.SizeChanged - = New resize changed event handler (this.OnTrackSizeChanged); } FrameworkElement as this._track = base.GetTemplateChild ("PART_Track"); FrameworkElement as this._indicator = base.GetTemplateChild ("PART_Indicator"); FrameworkElement as this._glow = base.GetTemplateChild ("PART_GlowRect"); If (this._track! = Null) {this._track.SizeChanged + = New shape changed event handler (this.OnTrackSizeChanged); } If (set this.) {This.SetProgressBarGlowElementBrush (); }}  

..

  Private Zero SetprogressBarIndicatorLength () {if ((this._track! = Null) & amp; (this._indicator! = Null)) {double minimum = base. the minimum; Double Max = Base. Maximum; Double num3 = base.Value; Double number 4 = (this.Initarmant || (max; = minimum))? 1.0: ((num3 - minimum) / (max - minimum)); This._indicator.Width = num4 * this._track.ActualWidth; This.UpdateAnimation (); }}  

% does not take into account, are you sure that the Part_ indicator is not the size correctly, but then you part_glowact Based on the wrong value?


No comments:

Post a Comment