How can I stop the WPF ProgressBar pulsing/animating when it reaches 100%?

后端 未结 5 1014
心在旅途
心在旅途 2021-02-05 03:52

I have an MVVM-based WPF 4 application which uses a ProgressBar to show the percentage completion of a long-running operation.



        
5条回答
  •  猫巷女王i
    2021-02-05 04:29

    You can swap the converter being used by PART_Indicator which by default is the ProgressBarBrushConverter which is where the animation is coming from...

    ...
    
    TranslateTransform transform = new TranslateTransform();
    double num11 = num8 * 100;
    DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
    animation.Duration = new Duration(TimeSpan.FromMilliseconds(num11));
    animation.RepeatBehavior = RepeatBehavior.Forever;
    for (int i = 1; i <= num8; i++)
    {
        double num13 = i * num7;
        animation.KeyFrames.Add(new DiscreteDoubleKeyFrame(num13, KeyTime.Uniform));
    }
    transform.BeginAnimation(TranslateTransform.XProperty, animation);
    
    ...
    

    The default logic for the ProgressBarBrushConverter can then be modified to suit your needs.

    You may have to end up passing parameters to the converter so that it can check the value and provide the appropriate animation or lack thereof contingent on the state of the ProgressBar.

提交回复
热议问题