我如何添加约束手机8.1 UAP Xaml

时间:2015-07-21 16:37:38

标签: c# xaml windows-phone-8 windows-phone-8.1

当我在Windows Phone 8.1 wvga 4"中查看我的应用程序时屏幕工作正常,如下面的屏幕截图所示

wvga 4" image

但是当我在我的5" lumia上查看时,它似乎在屏幕截图中显示了消息

5"lumia image

我知道iPhone使用约束系统将所有分辨率的物品保存在windows phone 8.1中类似的东西

<Page
x:Class="findaPhysio.findaPhysioSearchDetails"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:findaPhysio"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
    xmlns:drawerLayout="using:DrawerLayout"

Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid x:Name="RootLayout">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <!--Title bar -->
    <Grid x:Name="TitleBar" Background="#373A36"  Grid.Row ="0" Height="60">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Image Margin="5"  x:Name="DrawerIcon"  Grid.Column="0" Source="/Assets/ic_drawer.png" HorizontalAlignment="Left" Tapped="DrawerIcon_Tapped" />
        <TextBlock Grid.Column="1" Text="findaPhysio" Foreground="White" VerticalAlignment="Center" FontSize="18"/>
    </Grid>
    <!--DrawerLayout bar -->
    <drawerLayout:DrawerLayout Grid.Row="1"  x:Name="DrawerLayout">
        <!--MainPage -->
        <Grid x:Name="MainFragment" Background="White">
            <local:MapView  x:Name="MyMap" Background="Black"  Zoom="5" ShowTraffic="True" Margin="10,51,0,325" Loaded="MyMap_Loaded"/>
            <TextBlock HorizontalAlignment="Left" Margin="18.167,281.833,0,0" FontSize="18" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="85" Foreground="Black" Height="31" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto">
                <TextBlock.RenderTransform>
                    <CompositeTransform SkewX="4.332" TranslateX="1.174"/>
                </TextBlock.RenderTransform>
            </TextBlock>
            <TextBlock x:Name="txtAddress" HorizontalAlignment="Left" FontSize="18" Margin="116,282,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="175" Foreground="Black" RenderTransformOrigin="2.554,0.897"/>
            <TextBlock HorizontalAlignment="Left" Margin="22,257,0,0" FontSize="18" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" RenderTransformOrigin="0,0.256" Foreground="Black" IsTextSelectionEnabled="True"/>
            <TextBlock x:Name="txtTelephone" HorizontalAlignment="Left" FontSize="18" Margin="116,331,0,0" TextWrapping="Wrap" Text="Telephone" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="143"/>
            <TextBlock HorizontalAlignment="Left" Margin="16,331,0,0" FontSize="18" TextWrapping="Wrap" Text="Telephone" VerticalAlignment="Top" Foreground="Black"/>
            <TextBlock HorizontalAlignment="Left" Margin="16,325,0,0" FontSize="18" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Foreground="Black"/>
            <Button x:Name="btnBookNow" Content="Book Now" HorizontalAlignment="Left" Margin="108,427,0,0" VerticalAlignment="Top" Foreground="#FF589E5B" Background="#FF71C975" Tapped="btnBookNow_Tapped"/>
            <TextBlock HorizontalAlignment="Left" Margin="16,304,0,0" FontSize="18" TextWrapping="Wrap" Text="Town" VerticalAlignment="Top" Foreground="Black"/>
            <TextBlock x:Name="txtName" HorizontalAlignment="Left" Margin="116,257,0,0" FontSize="18" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" RenderTransformOrigin="0,0.256" Foreground="Black" IsTextSelectionEnabled="True"/>
            <TextBlock x:Name="txtTown" HorizontalAlignment="Left" Margin="116,304,0,0" FontSize="18" TextWrapping="Wrap" Text="Town" VerticalAlignment="Top" Foreground="Black"/>
            <TextBlock HorizontalAlignment="Left" Margin="16,358,0,0" FontSize="18" TextWrapping="Wrap" Text="Web" VerticalAlignment="Top" Foreground="Black"/>
            <TextBlock x:Name="txtWeb" HorizontalAlignment="Left" FontSize="12" Margin="116,358,0,0" TextWrapping="Wrap" Text="Web" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="263" Height="22"/>
            <TextBlock x:Name="lblsp" HorizontalAlignment="Left" Margin="16,385,0,0" FontSize="18" TextWrapping="Wrap" Text="Speciality" VerticalAlignment="Top" Foreground="Black"/>
            <TextBlock x:Name="txttxtSpeciality" HorizontalAlignment="Left" FontSize="18" Margin="116,385,0,0" TextWrapping="Wrap" Text="Speciality" VerticalAlignment="Top" Foreground="Black" Tapped="txtTelephone_Tapped" Width="143"/>



        </Grid>
        <!--Favorites List Section -->
        <Grid x:Name="ListFragment">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Border Grid.Row="0" Background="#5490CC">
                <TextBlock HorizontalAlignment="Center" Margin="0,5,0,5" Text="Physio Details"
                                FontSize="25"/>
            </Border>
            <ListView Grid.Row="1" VerticalAlignment="Center" x:Name="ListMenuItems">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Background="White" Margin="0,0,0,1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0"   Text="{Binding}" Margin="10"  VerticalAlignment="Center" FontSize="18" Foreground="Black" />
                            <Rectangle Grid.Row="1" HorizontalAlignment="Left" Fill="Gray" Width="500" Height="0.5"/>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

        </Grid>
    </drawerLayout:DrawerLayout>
</Grid>

1 个答案:

答案 0 :(得分:1)

您应该使用GridColumns GridRows属性Grid控制XAML。您的分辨率有问题,因为您对TextBlocks的边距进行了硬编码。你应该写:

<Grid>
   <Grid.RowDefinitions>
      <RowDefition />
      ......
   </Grid.RowDefinitions/>
   <Grid.ColumnDefinitions>
      ....
   </Grid.ColumnDefiniti‌​ons/>
.....
</Grid>

TextBlock插入需要的列和行后,例如:

 <TextBlock Grid.Row="1" Grid.Column="1" />