多次设置属性'Content' - XAML



每次我尝试在我的主页中实现<maps:Map IsShowingUser="True" x:Name="Mapa" />时,都会显示"属性'内容'被设置了不止一次"。每次我把这个地方给我"属性'内容'被设置了不止一次'。

如果有人能用简单的术语解释 Content 属性的设置位置,那将是最有帮助的。

<ContentPage xmlns:maps="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" 
x:Class="Pap.MainPage">
<maps:Map IsShowingUser="True" x:Name="Mapa" />
<AbsoluteLayout VerticalOptions="FillAndExpand" x:Name="Main">

<StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" x:Name="main" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Image Source="C:UsersdavidDesktopPapPapPap.AndroidResourcesdrawableUser.png" Aspect="AspectFill" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></Image>
</StackLayout>
<StackLayout x:Name="body" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"
Orientation="Vertical" VerticalOptions="FillAndExpand" Spacing="0">
<!--<StackLayout VerticalOptions="End" BackgroundColor="Red">
<Label Text="Titulo" />

</StackLayout>-->
<StackLayout VerticalOptions="FillAndExpand">
<Label Text="Slider-Example"  HorizontalOptions="Center" VerticalOptions="Center"/>
<Image Source="C:UsersdavidDesktopPapPapPap.AndroidResourcesdrawableUser.png" Aspect="AspectFill"></Image>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="Handle_Tapped">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</StackLayout>
</AbsoluteLayout>
</ContentPage>

ContentPage具有可以包含单个子元素的隐式Content属性。 如果要在页面上包含多个内容,则需要使用 Layout 容器,例如StackLayout

<ContentPage ... >
<StackLayout>
... multiple children can go here
</StackLayout>
</ContentPage>

如果使用 C# 而不是 XAML,则应显式设置Content属性

myPage.Content = new StackLayout{ ... };

最新更新