Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting child height or width to parent control same as "match_parent" in android

I have a page which includes a grid and within that grid there is a map. But I'm not able to set the size of map same as grid size. Though I can set it in code as

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

But how can I set it in 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>
like image 592
Inder Kumar Rathore Avatar asked Feb 14 '13 06:02

Inder Kumar Rathore


1 Answers

You should set the HorizontalAlignment and VerticalAlignmentof the map control to Stretch

<maps:Map x:Name="MyMap"
          HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch"
          Center="47.6097, -122.3331"
          ZoomLevel="10" />
like image 186
Olivier Payen Avatar answered Oct 16 '22 15:10

Olivier Payen