Question

Hej

I have an app where I need operate in landscape mode. THe problem is when I login with LiveId, I have to set the orientation to Portrait, because of the liveid only supports portrait mode.

The problem for me is that I want to show a popup in landscape mode, even if the system is in portrait mode.

I have tried with rotation, and doing some code when the rotation happens:

 private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        // Switch the placement of the buttons based on an orientation change.
        if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
        {

        }
        // If not in portrait, move buttonList content to visible row and column.
        else
        {
        }
    } 

But with no success. Anyone know how to display a popup in landscape mode, even when the orientation changes.

I hope somebody can help, because after several days, I have not been able to solve the problem.

Était-ce utile?

La solution

You simply have to use Composit Transform, and playaround with center, rotate and translate. However you have to use the code snippet I put above. Since you would need to make code for both the landscapeLeft and LandscapeRight

if ((e.Orientation & PageOrientation.LandscapeLeft) == PageOrientation.LandscapeLeft)
        {
            rotate = false;
        }
        else if ((e.Orientation & PageOrientation.LandscapeRight) == PageOrientation.LandscapeRight)
        {
            rotate = true;
        }
        if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
        {
            if (!rotate) { 
                CompositeTransform Trans = new CompositeTransform();
                Trans.Rotation = 90;

                Trans.TranslateY=-200;
                Trans.TranslateX = -120;

                Trans.CenterY = 400;
                Trans.CenterX = 200;
                popup.RenderTransform = Trans;
            }
            else
            {
                CompositeTransform Trans = new CompositeTransform();
                Trans.Rotation = -90;

                Trans.TranslateY = 200;
                Trans.TranslateX = 200;
                Trans.CenterY = 400;
                Trans.CenterX = 200;
                popup.RenderTransform = Trans;
            }
            /*RotateTransform myRotateTransform = new RotateTransform();
            if (rotate)
            {
                myRotateTransform.Angle = 90;
                myRotateTransform.CenterY = popup.ActualHeight / 2;
                myRotateTransform.CenterX = popup.ActualWidth / 2;

                popup.RenderTransform = myRotateTransform;
            }*/

        }
        // If not in portrait, move buttonList content to visible row and column.
        else
        {
        }
  }

That is what I ended up with, and it solved my problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top