469,343 Members | 5,350 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

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 18610
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.