我知道弹出窗口和定向存在问题。我已经读过,如果弹出窗口在可视树中,则它应该遵循方向。我有两种类型的弹出窗口,一种是全局的(不在视觉树中),另一种是在特定页面xaml上定义的。我还没有与全球事务打交道,但是我希望让特定页面的工作正常。
这是我的xaml:
x:Class="Views.MainPanorama"
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:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:toolkitPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape"
shell:SystemTray.IsVisible="False">
<toolkit:TransitionService.NavigationInTransition>
<toolkit:NavigationInTransition>
<toolkit:NavigationInTransition.Backward>
<toolkit:TurnstileTransition Mode="BackwardIn"/>
</toolkit:NavigationInTransition.Backward>
<toolkit:NavigationInTransition.Forward>
<toolkit:TurnstileTransition Mode="ForwardIn"/>
</toolkit:NavigationInTransition.Forward>
</toolkit:NavigationInTransition>
</toolkit:TransitionService.NavigationInTransition>
<toolkit:TransitionService.NavigationOutTransition>
<toolkit:NavigationOutTransition>
<toolkit:NavigationOutTransition.Backward>
<toolkit:TurnstileTransition Mode="BackwardOut"/>
</toolkit:NavigationOutTransition.Backward>
<toolkit:NavigationOutTransition.Forward>
<toolkit:TurnstileTransition Mode="ForwardOut"/>
</toolkit:NavigationOutTransition.Forward>
</toolkit:NavigationOutTransition>
<ScrollViewer x:Name="mainScroll">
<Grid x:Name="LayoutRoot" Style="{StaticResource BackgroundStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image x:Name="icon" Source="/Folder;component/Images/Icons/logo.png" Height="24" Width="175" HorizontalAlignment="Left" Margin="20, 15, 0, 0" />
<controls:Panorama Name="panMain" HeaderTemplate="{StaticResource PanoramaHeaderTemplate}" Grid.Row="1" Margin="0, -10, 0, 0" Height="680">
<!--Panorama definition here-->
</controls:Panorama>
<gbl:SecureFooter ShowLock="True" x:Name="panoFoot" Grid.Row="2" VerticalAlignment="Bottom" Margin="24, 24, 24, 0" />
<Popup x:Name="_popup" Grid.Row="3" />
</Grid>
</ScrollViewer>
该页面正常工作,并显示弹出窗口,但是当我旋转手机或仿真器时,弹出窗口的内容不会改变方向。
我使用以下代码在弹出窗口中设置内容:
_popup.Child = new OneOfTwoPopupUserControls();
这会导致弹出窗口忽略方向吗?在xaml中创建它时,是否需要完整的内容?
最佳答案
据我了解,弹出窗口位于页面的可视树之外,因为页面是处理方向更改的因素,所以弹出窗口本身不会受到影响。
我使用的唯一解决方案是监听方向更改的事件,并对弹出内容进行自己的转换。不理想,对我来说效果不佳。最后,我放弃了弹出窗口。
抱歉,我帮不上忙。
关于c# - 视觉树中的WP7弹出窗口不尊重方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4937541/