locked
How to animate a fly-in box to the centre of the screen regardless of orientation? RRS feed

  • Question

  • Hi,

    I'm using Blend with Visual Studio 2013 Pro, so hope this question is relevant here...

    I want to animate a box to fly into the center of the screen and then fly out again after a delay.

    No problem achieving this with the device set to landscape orientation, but if I change to portrait orientation the box no longer flies to the centre of the screen, it goes too far.

    Is there a way that instead of specifying absolute position for the translate, I can specify it to be half the screen width?

    Or is there another way I can guarantee my box translates to the centre of the screen regardless of screen orientation?

    Thanks - Rich

    Wednesday, September 17, 2014 7:33 PM

All replies

  • Hi

    you have to create separate visual states for landscape and portrait and in each you will define  the animated  box to fly and set the box at centre.

    Thanks 

    • Proposed as answer by Faizan Amjad Wednesday, September 17, 2014 7:37 PM
    Wednesday, September 17, 2014 7:37 PM
  • Thanks for the fast reply Faizan,

    I actually managed to get it working by deleting the animation, then making sure my box was contained within a grid and was set to be horizontally and vertically centred within it. Flipping between landscape and portrait in the designer now meant that my box remained in the centre of the screen.

    Now when I applied the translate animation the box flew to the centre each time.

    I will bear in mind what you said about visual states though, that makes a lot of sense.

    Rich

    Wednesday, September 17, 2014 8:03 PM