Search code examples
silverlightwindows-phone-7canvasorientation-changes

WP7 Game - rotate only some controls when orientation changed


I'm making a simple WP7 game and I have a little problem with orientation changing. My gameboard looks like this:

enter image description here

And I need to rotate only the numbers when orientation changed. Is there any easy way to do it? The numbers are TextBlocks and lines are rectangles. Gameboard is Canvas (but I can use Grid as well).

Or i could exclude the canvas from automatic rotating and only redraw the numbers. But I don't know how to do it either.


Solution

  • Using PlaneProjection should be fine:

    <TextBlock.Projection>
      <PlaneProjection RotationZ="90"/>
    </TextBlock.Projection>
    

    Obviously this would apply the projection immediately, so you would need to create it in code (or try using 0 for the Z value and then changing that in code (possibility of this is a long shot)) based on the data provided (and within) the OrienationChanged event handler, such as:

    myTextBlock.Projection = new PlaneProjection { RotationZ = 90 };