Rotate Control at Center Point in XAML

This is my Grid

<Grid>
    <Grid.RenderTransform>
        <RotateTransform Angle="-180" />
    </Grid.RenderTransform>
</Grid>

However, it will be in the wrong position (I want it to rotate on the center point). Hence I need to do something like this:

<Grid.RenderTransform>
    <RotateTransform CenterX="{Binding ???}" CenterY="{Binding ???}" Angle="-180" />
</Grid.RenderTransform>

I'm not sure how to do the binding here (calculating the Grid's width/2 and height/2). Can someone give a hand? :)

Answers


Try set RenderTransformOrigin for Grid:

<Grid RenderTransformOrigin="0.5,0.5" ... />

Quote from MSDN:

RenderTransformOrigin: Gets or sets the center point of any possible render transform declared by RenderTransform, relative to the bounds of the element.


Need Your Help

.substring() while dealing with multibyte characters in Java on Unix/Linux

java encoding decoding multibyte

I have an encoded string (creation of which i have no information about and possibly cannot alter) which has 8 random characters at the beginning (before encoding and after decoding). And then vali...

tooltip catcher c#

c# tooltip diagnostics

I want to create an application which can copy the tool tip (the tool tips which are shown on the current desktop/window) if I press hot keys. So how can I track whether the current desktop having ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.