ProgressBar flicker problem

Mar 10, 2009 at 4:26 PM
Most of the styles for the progress bars are not smooth and have a flicker. Ive corrected this for expression dark :)

 

<Style

 

TargetType="ProgressBar">

 

<Setter

 

Property="Foreground" Value="{StaticResource NormalBrush}" />

 

<Setter

 

Property="Background" Value="{StaticResource ControlBackgroundBrush}" />

 

<Setter

 

Property="BorderThickness" Value="1" />

 

<Setter

 

Property="Maximum" Value="100" />

 

<Setter

 

Property="IsTabStop" Value="False" />

 

<Setter

 

Property="BorderBrush" Value="{StaticResource GlyphBrush}" />

 

<Setter

 

Property="Template">

 

<Setter.Value>

<ControlTemplate

 

TargetType="ProgressBar">

 

<Grid

 

x:Name="Root">

 

 

<Border

 

x:Name="PART_Track" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" />

 

<Grid

 

x:Name="ProgressBarRootGrid">

 

<Rectangle

 

Margin="{TemplateBinding BorderThickness}" x:Name="ProgressBarRootGradient" Canvas.ZIndex="1" RadiusX="1.5" RadiusY="1.5" Stroke="#FFFFFFFF" StrokeThickness="1" Opacity="0">

 

<Rectangle.Fill>

<LinearGradientBrush

 

EndPoint=".7,1" StartPoint=".7,0">

 

<GradientStop

 

Color="#B2FFFFFF" Offset="0" />

 

<GradientStop

 

Color="#C6FFFFFF" Offset="0.15" />

 

<GradientStop

 

Color="#D1FFFFFF" Offset="0.275" />

 

<GradientStop

 

Color="#C6FFFFFF" Offset="0.4" />

 

<GradientStop

 

Color="#BFFFFFFF" Offset="0.65" />

 

<GradientStop

 

Color="#A5FFFFFF" Offset="0.75" />

 

<GradientStop

 

Color="#91FFFFFF" Offset="0.85" />

 

<GradientStop

 

Color="#72FFFFFF" Offset="1" />

 

</LinearGradientBrush>

</Rectangle.Fill>

</Rectangle>

<Grid

 

x:Name="IndeterminateRoot" Visibility="Collapsed">

 

<Rectangle

 

Margin="{TemplateBinding BorderThickness}" x:Name="IndeterminateSolidFill" Opacity="1" RenderTransformOrigin="0.5,0.5" RadiusX="2" RadiusY="2" Fill="{TemplateBinding Foreground}" Stroke="#FF448DCA" StrokeThickness="0" />

 

<Rectangle

 

Margin="{TemplateBinding BorderThickness}" x:Name="IndeterminateGradientFill" RadiusX="2" RadiusY="2" StrokeThickness="1">

 

<Rectangle.Fill>

<LinearGradientBrush

 

EndPoint="0,1" StartPoint="80,1" MappingMode="Absolute" SpreadMethod="Repeat">

 

<GradientStop

 

Color="#00FFFFFF" />

 

<GradientStop

 

Color="#FEA1A1A1" Offset="1" />

 

<GradientStop

 

Color="#00FEFEFE" Offset="0.517" />

 

<GradientStop

 

Color="#FEA1A1A1" Offset="0.517" />

 

<LinearGradientBrush.Transform>

<TransformGroup>

<TranslateTransform

 

X="0" />

 

<SkewTransform

 

AngleX="-60"/>

 

</TransformGroup>

</LinearGradientBrush.Transform>

</LinearGradientBrush>

</Rectangle.Fill>

</Rectangle>

</Grid>

<Grid

 

Margin="1" x:Name="DeterminateRoot">

 

<Rectangle

 

HorizontalAlignment="Left" Margin="{TemplateBinding BorderThickness}" x:Name="PART_Indicator" RadiusX="1.5" RadiusY="1.5" Fill="{TemplateBinding Foreground}" StrokeThickness="0.5" />

 

</Grid>

</Grid>

</Grid>

<ControlTemplate.Triggers>

<Trigger

 

Property="IsIndeterminate" Value="True">

 

<Trigger.EnterActions>

<BeginStoryboard>

<Storyboard

 

RepeatBehavior="Forever">

 

<ObjectAnimationUsingKeyFrames

 

Duration="00:00:00" Storyboard.TargetName="IndeterminateRoot" Storyboard.TargetProperty="(UIElement.Visibility)">

 

<DiscreteObjectKeyFrame

 

KeyTime="00:00:00">

 

<DiscreteObjectKeyFrame.Value>

<Visibility>

 

Visible</Visibility>

 

</DiscreteObjectKeyFrame.Value>

</DiscreteObjectKeyFrame>

</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames

 

Duration="00:00:00" Storyboard.TargetName="DeterminateRoot" Storyboard.TargetProperty="(UIElement.Visibility)">

 

<DiscreteObjectKeyFrame

 

KeyTime="00:00:00">

 

<DiscreteObjectKeyFrame.Value>

<Visibility>

 

Collapsed</Visibility>

 

</DiscreteObjectKeyFrame.Value>

</DiscreteObjectKeyFrame>

</ObjectAnimationUsingKeyFrames>

<DoubleAnimationUsingKeyFrames

 

Storyboard.TargetName="IndeterminateGradientFill" Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.Transform).(TransformGroup.Children)[0].X">

 

<SplineDoubleKeyFrame

 

KeyTime="0" Value="0" />

 

<SplineDoubleKeyFrame

 

KeyTime="00:00:1.33" Value="80" />

 

</DoubleAnimationUsingKeyFrames>

</Storyboard>

</BeginStoryboard>

</Trigger.EnterActions>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>