Windows Phone中的C#定向

本文关键字:定向 中的 Phone Windows | 更新日期: 2023-09-27 18:29:47

我是Windows Phone的业余爱好者,如何在横向模式和纵向模式下自动更改方向大小?

在C#WinForms中,我可以使用Dock或Anchor,它完全可以工作,但在windows phone中我不能。

这是我的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>

我尝试将所有控件的宽度设置为自动,但没有成功。

感谢

Windows Phone中的C#定向

如果我理解正确,无论在什么屏幕大小或比例上启动,你都希望你的UI看起来是一样的。你可以使用canvas controll并将界面元素放置在其中,但唯一应该使用的答案是:不要使用硬编码值,而是使用starsAuto。你的用户界面在每个屏幕上都会看起来很棒您的列/行将进行拉伸/收缩,以适应用户手机的高度和宽度

更多信息和示例:适用于Windows Phone 8 的多分辨率应用程序