472,127 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 19407
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mickel Grönroos | last post: by
17 posts views Thread by santel_helvis | last post: by
8 posts views Thread by lovecreatesbeauty | last post: by
8 posts views Thread by Samuel Shulman | last post: by
reply views Thread by jubi | last post: by

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.