我是Windows Phone的业余爱好者, 如何在横向模式和纵向模式下自动更改方向尺寸?
在C#WinForms中,我可以使用Dock或Anchor,它完全正常,但在Windows手机中,我不能。
这是我的XAML代码,是否可以帮助我?
<phone:PhoneApplicationPage
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"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:local="clr-namespace:testApp"
x:Class="testApp.DLPage"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
Background="#FF262626"
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>
</toolkit:TransitionService.NavigationOutTransition>
<ScrollViewer HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid x:Name="gridOrg" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Height="800" >
<Grid x:Name="gridPanel" HorizontalAlignment="Left" Height="780" Margin="10,10,0,0" VerticalAlignment="Top" Width="460" Background="#FF3E3E3E">
<Ellipse x:Name="elp" HorizontalAlignment="Left" Height="455" Margin="4,4,0,0" Stroke="Black" VerticalAlignment="Top" Width="453" Tap="elp_Tap"/>
<TextBlock x:Name="txtTitle" HorizontalAlignment="Left" Margin="6,478,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="162" Width="447"/>
<TextBlock x:Name="cntDL" HorizontalAlignment="Left" Margin="6,662,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="52" Width="447"/>
</Grid>
<local:LoadingControl x:Name="pb" HorizontalAlignment="Left" Margin="10,377,0,0" VerticalAlignment="Top" Width="460"/>
</Grid>
</ScrollViewer>
</phone:PhoneApplicationPage>
我尝试为所有控件设置自动宽度但不起作用。
感谢
答案 0 :(得分:1)
如果我理解正确,您希望无论您使用的屏幕大小或比率如何,您的用户界面看起来都一样。您可以使用canvas controll并将界面的元素放在其中,但您唯一应该接受的答案是:不要使用硬编码值,使用星星和<强>自动代替。您的UI在每个屏幕上看起来都很棒。 您的列/行将进行拉伸/缩小以适合用户手机的高度和宽度。