Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:38:13+00:00 2026-06-07T05:38:13+00:00

I have an animation inside a Behavior, but it is not running fluid. Here

  • 0

I have an animation inside a Behavior, but it is not running fluid.

Here is my animation code:

DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();

animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(0).(1)", UIElement.RenderTransformProperty, RotateTransform.AngleProperty));

int keyFrameCount = 16;
double timeOffsetInSeconds = 0.1;
int targetValue = 12;

double totalAnimationLength = keyFrameCount * timeOffsetInSeconds;
double repeatInterval = RepeatInterval;
bool isShaking = IsShaking;

// Can't be less than zero and pointless to be less than total length
if (repeatInterval < totalAnimationLength)
    repeatInterval = totalAnimationLength;

animation.Duration = new Duration(TimeSpan.FromSeconds(repeatInterval));

for (int i = 0; i < keyFrameCount; i++)
{
    animation.KeyFrames.Add(new LinearDoubleKeyFrame(i % 2 == 0 ? targetValue : -targetValue, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i * timeOffsetInSeconds))));
}

animation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(totalAnimationLength))));

But, if i choose

int keyFrameCount = 360;

and

for (int i = 0; i < keyFrameCount; i++)
{
    animation.KeyFrames.Add(new LinearDoubleKeyFrame(i, keyTime.FromTimeSpan(TimeSpan.FromSeconds(i * timeOffsetInSeconds))));
}

it will rotate a very smooth circle.

How can I achieve to let the animation go from 0 to 30 degrees, back to -30 degrees,
and then back to 0 (to let it dither around a bit) AND have it look fluent.

After some tries, I see that (normal) back and forth will not work here,
it behaves totally uncontrolled!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:38:14+00:00Added an answer on June 7, 2026 at 5:38 am

    I’m not really sure why you’re doing so many keyframes yourself, but in order to do

    How can I achieve to let the animation go from 0 to 30 degrees, back to -30 degrees, and then back to 0 (to let it dither around a bit) AND have it look fluent.

    You could change the animation to something like

    DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
    
    animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(0).(1)", UIElement.RenderTransformProperty, RotateTransform.AngleProperty));
    
    var totalAnimationLength = 1600; // Milliseconds
    
    double repeatInterval = 1600;// Milliseconds
    
    if (repeatInterval < totalAnimationLength) repeatInterval = totalAnimationLength; // Can't be less than zero and pointless to be less than total length 
    
    animation.Duration = new Duration(TimeSpan.FromMilliseconds(repeatInterval));
    animation.RepeatBehavior = RepeatBehavior.Forever; // assuming this was intended from having a repeat interval?
    
    animation.KeyFrames.Add(new LinearDoubleKeyFrame(30, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(totalAnimationLength * 0.25))));
    animation.KeyFrames.Add(new LinearDoubleKeyFrame(-30, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(totalAnimationLength * 0.75))));
    animation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(totalAnimationLength))));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple jquery animation on a div, which is inside a div,
I have a animation of moving blocks but I would like to add feature
I have an animation running in the background, and I want to register a
Title is quite self explanatory, but I have some animation being done in a
I have put a line of code inside the UIAnimation block. And the next
I have a problem I don't understand regarding UIViews and Core Animation. Here's what
I have a ColorAnimation inside a Storyboard. After that Storyboard finishes I want to
I have a function inside my .aspx.cs code which takes wuite a long time
I have a Dialog with a form inside. The following code is just an
I have a fadeout animation in a view (which is inside a fragment), and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.