473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 19851
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.