2012-04-21 47 views
0

我正在Silverlight中開發WP7應用程序。我差不多完成了,但是我需要在縱向視圖中插入新的用戶控件作爲橫向根頁面的子元素。 每個子元素(不包括此)都處於橫向模式,並且不能更改。向橫向頁面添加縱向子元素

當我將SupportOrientation更改爲RootPage中的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> 

用戶控制監聽狀態機他的狀態然後將其自身添加爲RootPage的Canvas。

請幫我:)

回答