473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WPF rotate canvas

I'm working in a WPF windows application and am wondering if it's possible
to rotate a Canvas or user control derived from Canvas. I created a user
control which derives from Canvas and I need to rotate it 90, 180, and 270
degrees. Is this possible and if so, how would I do it? The use control
lives in a main canvas.

Thanks.

--
mo*******@noemail.noemail
Feb 15 '07 #1
3 19840
moondaddy wrote:
I'm working in a WPF windows application and am wondering if it's possible
to rotate a Canvas or user control derived from Canvas. I created a user
control which derives from Canvas and I need to rotate it 90, 180, and 270
degrees. Is this possible and if so, how would I do it? The use control
lives in a main canvas.

Thanks.
Is such Xaml suitable your requirement?
<Canvas Width="200" Height="200" Background="Yellow">
<Canvas.RenderTransform>
<RotateTransform CenterX="100" CenterY="100" Angle="60" />
</Canvas.RenderTransform>
<Button Canvas.Left="50" Canvas.Top="50" >button1</Button>
</Canvas>

--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
Feb 15 '07 #2
Thanks. this works good, but I need to do it all from c#. Can you show an
example of this from the button click event? I see plenty of xaml examples
online, but no c# examples of working with RotateTransform.

Thanks again.

"jacky kwok" <ja********@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
moondaddy wrote:
>I'm working in a WPF windows application and am wondering if it's
possible to rotate a Canvas or user control derived from Canvas. I
created a user control which derives from Canvas and I need to rotate it
90, 180, and 270 degrees. Is this possible and if so, how would I do it?
The use control lives in a main canvas.

Thanks.

Is such Xaml suitable your requirement?
<Canvas Width="200" Height="200" Background="Yellow">
<Canvas.RenderTransform>
<RotateTransform CenterX="100" CenterY="100" Angle="60" />
</Canvas.RenderTransform>
<Button Canvas.Left="50" Canvas.Top="50" >button1</Button>
</Canvas>

--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk

Feb 23 '07 #3
I found the answer:

void ButtonClick(object sender, RoutedEventArgs e)
{
canv1.RenderTransform = new RotateTransform(90,100,100);
}

"moondaddy" <mo*******@noemail.noemailwrote in message
news:uF**************@TK2MSFTNGP02.phx.gbl...
Thanks. this works good, but I need to do it all from c#. Can you show
an example of this from the button click event? I see plenty of xaml
examples online, but no c# examples of working with RotateTransform.

Thanks again.

"jacky kwok" <ja********@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>moondaddy wrote:
>>I'm working in a WPF windows application and am wondering if it's
possible to rotate a Canvas or user control derived from Canvas. I
created a user control which derives from Canvas and I need to rotate it
90, 180, and 270 degrees. Is this possible and if so, how would I do
it? The use control lives in a main canvas.

Thanks.

Is such Xaml suitable your requirement?
<Canvas Width="200" Height="200" Background="Yellow">
<Canvas.RenderTransform>
<RotateTransform CenterX="100" CenterY="100" Angle="60" />
</Canvas.RenderTransform>
<Button Canvas.Left="50" Canvas.Top="50" >button1</Button>
</Canvas>

--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk


Feb 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mickel Grönroos | last post by:
Hi, I'm trying to put an Tkinter.Entry of fixed size onto a specific location on a canvas using the place manager. The idea is that one can double-click a rectangle object on a canvas to get an...
17
by: santel_helvis | last post by:
Hi All, Could anyone tell me how to rotate the image in javascript. Which concepts I should concentrate to rotate the image
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
8
by: Samuel Shulman | last post by:
Is it possible and how to rotate pictures in HTML document Thank you, Samuel
2
TMS
by: TMS | last post by:
Schools over!!! Now its time to play. I would like to learn how to make objects move from one location to the next on a canvas widget. For example: from Tkinter import * class square:...
6
by: Nebulism | last post by:
I have been attempting to utilize a draw command script that loads a canvas, and through certain mouse events, draws rectangles. The original code is from...
0
by: jubi | last post by:
I'm searching an algorithm to rotate a X11 pixmap (in C with xlib). I'm drawing on a tk canvas (which is implemented as a X11 Pixmap) and want to rotate all elements i have drawn on it (it's a city...
4
by: moondaddy | last post by:
I have a wpf project where I use a canvas to drag shapes around. when I drag a shape beyond the right or bottom side I get scrollbars which is good. I also get scrollbars when I zoom in and a...
0
by: harryusa | last post by:
I am experimenting with the rotate function and so far I can't get my code to return anything but the URL of my script. Here it is: <?php // The file you are rotating $image =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.