Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将父控件的子高度或宽度设置为与“相同”;匹配“家长”;在android中_C#_Xaml_Windows 8_Windows Phone 8 - Fatal编程技术网

C# 将父控件的子高度或宽度设置为与“相同”;匹配“家长”;在android中

C# 将父控件的子高度或宽度设置为与“相同”;匹配“家长”;在android中,c#,xaml,windows-8,windows-phone-8,C#,Xaml,Windows 8,Windows Phone 8,我有一个网页,其中包括一个网格和网格内有一个地图。但我无法将地图的大小设置为网格大小。虽然我可以在代码中将其设置为 MyMap.Height = LayoutRoot.ActualHeight; MyMap.Width = LayoutRoot.ActualWidth; 但是如何在xaml中设置它呢 <phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentatio

我有一个网页,其中包括一个网格和网格内有一个地图。但我无法将地图的大小设置为网格大小。虽然我可以在代码中将其设置为

MyMap.Height = LayoutRoot.ActualHeight;
MyMap.Width = LayoutRoot.ActualWidth;
但是如何在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>

您应该将地图控件的
水平对齐
垂直对齐
设置为
拉伸

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