0

我正在 Silverlight 中开发一个 WP7 应用程序。我几乎完成了,但我需要在纵向视图中插入新的用户控件作为横向根页面的子元素。每个子元素(不包括这个)都处于横向模式,无法更改。

当我在 RootPage 中将 SupportedOrientation 更改为 PortrailorLandscape 并将模拟器中的方向切换为纵向时,横向中的每个子元素都会被剪切。

这就是我所做的:

页面根代码:

<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>

然后将用户控件作为 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>

用户控件在状态机中侦听他的状态,然后将自己作为 Child 添加到 RootPage 的 Canvas 中。

请帮我:)

4

1 回答 1

0

我不确定您真正想要做什么,但是您可以尝试将 RenderTransform 应用于您的 UserControl,以使其保持纵向模式。

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

于 2012-05-14T15:58:36.310 回答