如何让WP7地图填满整个观看页面?

时间:2012-03-29 18:26:18

标签: windows-phone-7 windows-phone-7.1

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Image Margin="0" Grid.RowSpan="2" Source="Images/map_bg.jpg" Stretch="Fill"/>
        <my:Map Height="649" HorizontalAlignment="Left" Name="map1" VerticalAlignment="Top" Width="451" LogoVisibility="Collapsed"  Margin="2,0,0,0" />
    </Grid>

我尝试使用高度和宽度变量进行升技,但这只会改变地图的位置,而不是拉伸整个地图。

是否可以让地图“填充”整个<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">属性?
谢谢!

修改

 <Grid x:Name="LayoutRoot" Background="Transparent" Opacity="0.7">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"></StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Image Margin="0" Grid.RowSpan="2" Source="Images/map_bg.jpg" Stretch="Fill"/>
            <my:Map Name="map1" VerticalAlignment="Top" Width="451" LogoVisibility="Collapsed"  CredentialsProvider="xxx" Margin="2,0,0,0" Height="645" />
        </Grid>
    </Grid>

1 个答案:

答案 0 :(得分:2)

我删除了地图控件中的所有边距/大小/定位元素,让它自行展开。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <my:Map CredentialsProvider="abcdefg"  Name="map1"   >
        <my:MapLayer Name="mapLayer"/>
    </my:Map>
</Grid>