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

  • Home
  • SEARCH
  • 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 3679210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:25:58+00:00 2026-05-19T03:25:58+00:00

i am trying to rotate elements on a canvas and the save their rotated

  • 0

i am trying to rotate elements on a canvas and the save their rotated (not original) positions to a file. I implemented a custom UIElement control to display a custom graphic, however when the graphic is rotated on the screen it is rotated correctly (no problem there) however when i obtain the position of the element using GetValue(Canvas.LeftProperty) and GetValue(Canvas.TopProperty), the X, Y coordinates and the angle of the element is of position of the original image before rotation.

I am learning WPF to finish a project for school and thus my knowledge of the technology is not as vast as i would like but if anyone can help me i would greatly appreciate it, thank you.

this is the implementation of the code that i have:

CustomObject m;

List<CustomObject> co = new List<CustomObject>();  
foreach (var child in canvas1.Children){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m = child as CustomObject;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (m != null && m.IsEnabled && m.IsVisible){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SaveStructure m1 = new SaveStructure();  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>m1.Angle = Convert.ToSingle(ToRadians(m.Angle));</b>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>m1.X = Convert.ToInt32(m.GetValue(Canvas.LeftProperty));</b>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>m1.Y = Convert.ToInt32(m.GetValue(Canvas.TopProperty));</b>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;co.Add(m1);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
}   

Note: All i want to know is how to get the position of the rotated element on the canvas, because i keep obtaining the original (unrotated) position.

  • 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-05-19T03:25:58+00:00Added an answer on May 19, 2026 at 3:25 am

    The position you get is still the same because the object was not moved, it was just rotated, if you want to get the bounds of the rotated object that is something different than getting its position. You could do that by getting the corner point coordinates of the elements (Canvas.GetLeft(m), Canvas.GetTop(m), Canvas.GetLeft(m) + m.Width, Canvas.GetTop(m) + m.Height) and rotate them using the RotateTransform‘s Transform(Point p) method, then extract the bounds from those rotated points.

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

Sidebar

Related Questions

Trying to import a custom UITableViewCell and it keeps giving me a file not
Trying to make a make generic select control that I can dynamically add elements
Okay I'm trying to rotate a Java Polygon based on it's original position of
I am trying to rotate a canvas with canvas.rotate and move an object on
In OpenGL I'm trying to rotate a camera around a point, with camera being
Trying to perform a single boolean NOT operation, it appears that under MS SQL
I am trying to rotate a vector around a certain point on the vector(in
I'm trying to use the jQuery Cycle plugin (http://jquery.malsup.com/cycle/) to rotate testimonials located within
I am trying to rotate a Sprite in three dimensions around its centerpoint, and
Just as a learning experience, I am trying to make en element rotate on

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.