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 8493891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:08:43+00:00 2026-06-10T23:08:43+00:00

How to define XAML to rotate a rectangle infinitely? So far I found a

  • 0

How to define XAML to rotate a rectangle infinitely?

So far I found a solution with code but no xaml:
http://www.codeproject.com/Articles/23257/Beginner-s-WPF-Animation-Tutorial
which I use like this:

private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
    var doubleAnimation = new DoubleAnimation(360, 0, new Duration(TimeSpan.FromSeconds(1)));
    var rotateTransform = new RotateTransform();
    
    rect1.RenderTransform = rotateTransform;
    rect1.RenderTransformOrigin = new Point(0.5, 0.5);
    doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
    
    rotateTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
}

But how can I achieve this with XAML only?

  • 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-10T23:08:44+00:00Added an answer on June 10, 2026 at 11:08 pm

    Something like this

    <Rectangle x:Name="rect1" RenderTransformOrigin="0.5, 0.5">
      <Rectangle.RenderTransform>
        <!-- giving the transform a name tells the framework not to freeze it -->
        <RotateTransform x:Name="noFreeze" />
      </Rectangle.RenderTransform>
      <Rectangle.Triggers>
        <EventTrigger RoutedEvent="Loaded">
          <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation
                Storyboard.TargetProperty="(Rectangle.RenderTransform).(RotateTransform.Angle)"
                To="-360" Duration="0:0:1" RepeatBehavior="Forever" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Rectangle.Triggers>
    </Rectangle>
    

    Of course you can remove Loaded trigger and run this storyboard whenever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, the WPF namespace is: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" If I define my own namespace, should
Suppose the following XAML defined window: <Window x:Class=LayoutTests.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=clr-namespace:LayoutTests Title=Window1> <Window.Resources> <XmlDataProvider
It's simple enough to define an image in xaml and move it around, but
Here I have the XAML for a label, but I want to define it
I have a number of elements in my XAML which define Foreground=#555 to be
In XAML, you can define a size property (such a length or width) in
In my xaml code, inside the Window.Resources section, I have defined a Data Template
Like define in XAML file? I seen couples of example they were on define
I define DisplayHeight in my App.xaml file here: <Application.Resources> <sys:Int32 x:Key=DisplayHeight>534</sys:Int32> </Application.Resources> I try
I want to define the background for my application in App.XAML. The background was

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.