2013-02-14 11 views
6

Tôi có một trang bao gồm lưới và trong lưới đó có bản đồ. Nhưng tôi không thể đặt kích thước của bản đồ giống như kích thước lưới. Mặc dù tôi có thể đặt mã trong mã làĐặt chiều cao hoặc chiều rộng của trẻ thành kiểm soát của cha mẹ giống như "match_parent" trong android

MyMap.Height = LayoutRoot.ActualHeight; 
MyMap.Width = LayoutRoot.ActualWidth; 

Nhưng làm cách nào tôi có thể đặt trong 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:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps" 
    x:Class="MapSample.MainPage" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True"> 

    <Grid x:Name="LayoutRoot" Background="Red"> 
     <maps:Map x:Name="MyMap" HorizontalAlignment="Left" VerticalAlignment="Top" Center="47.6097, -122.3331" ZoomLevel="10"/> 
    </Grid> 

</phone:PhoneApplicationPage> 

Trả lời

11

Bạn nên thiết lập HorizontalAlignmentVerticalAlignment của sự kiểm soát bản đồ để Stretch

<maps:Map x:Name="MyMap" 
      HorizontalAlignment="Stretch" 
      VerticalAlignment="Stretch" 
      Center="47.6097, -122.3331" 
      ZoomLevel="10" />