David K
David K

Reputation: 3243

WP7: Rotating a popup + content?

I've been googling this issue for some time now, but havent been able to find a solution that worked for me. The thing is I have a popup control with a user control, in which the user can enter a new value for a listpicker. This all works fine in portrait mode, but if the phone is rotated (emulator), the popup remains in portrait mode. Opening the popup when phone is already in landscape, has no effect either.

Is there any way to correct this issue? I've seen some people suggesting using Rotatetransform, but if I do this on a textbox etc., it disappears completely :/

Upvotes: 5

Views: 1426

Answers (2)

Tuomas Hautakangas
Tuomas Hautakangas

Reputation: 31

Do not rorate the popup but place a border inside the popup and load the content in the border.

I got it to work like this:

//In .xaml
<Popup x:Name="myPopup">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="480" />
        </Grid.RowDefinitions>

        <Border x:Name="popupBorder"/>
    </Grid>
</Popup>

//In .xaml.cs
popupBorder.Child = new MyPopupPage(); //MyPopupPage is the "Windows Phone Landscape Page"
myPopup.IsOpen = true;

Upvotes: 2

Derek Lakin
Derek Lakin

Reputation: 16319

I think this is potentially a bug in the Popup control; I've certainly heard the question asked before. However, I've also heard that the performance of the Popup controls is not that great, so I think you'd be better off just using a regular framework element (such as a Grid) to contain your popup content and show/hide it (with animation if appropriate) accordingly. At least that way it will get rotated properly when the page orientation changes.

Upvotes: 4

Related Questions