简体   繁体   中英

Adding portrait child element to landscape page

I'm developing a WP7 app in silverlight. I almost done but, I need to insert new user-control in portrait view as a child element of landscape root page. Each child element (excluding this) is in landscape mode and it can't be changed.

When I change SupportedOrientation to PortrailorLandscape in RootPage and toggle orientation in emulator to portrait then every child element, that was in landscape, is cutted.

This is what I did:

Page root code:

<phone:PhoneApplicationPage 
    x:Class="app.Root"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Landscape" Orientation="LandscapeLeft"
    mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800" shell:SystemTray.IsVisible="False">
    <Grid  Width="800" Height="480" Loaded="RootGrid_Loaded">
        <Popup x:Name="myPopup">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="480"/>
                </Grid.RowDefinitions>
                <Border x:Name="popupBorder"/>
            </Grid>
        </Popup>
        <Canvas x:Name="ScreenRoot"
                      Visibility="Visible"
                      Width="800" Height="480">
<Canvas.Children/>
        </Canvas>
    </Grid>
</phone:PhoneApplicationPage>

Then user-control as a child of ScreenRoot:

<UserControl 
    x:Class="app.Settings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource OCRAExt}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="WhiteSmoke" 
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">
<Grid x:Name="SettingsRoot" Background="Black" Width="480" Height="800">
...
...
</Grid>
</UserControl>

User control listens his state in state machine and then add itself as a Child to Canvas of RootPage.

Please help me:)

I'm not sure to understand what you really want to do, but you can try to apply a RenderTransform to your UserControl, in order to keep it in portrait mode.

http://msdn.microsoft.com/en-us/library/ms754009.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM