我在我的view.Carousel中有一个旋转木马在网格view.and中,我也有一个按钮,但是问题是按钮没有到正确的位置。我想把寄存器按钮放在上面和全宽度。
这是我的看法

我的密码
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:InfutureMob"
x:Class="InfutureMob.MainPage"
xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView">
<Grid RowSpacing="0" Grid.RowSpan="2">
<!--<Grid.RowDefinitions>
<RowDefinition Height=".3*"/>
<RowDefinition Height=".7*"/>
</Grid.RowDefinitions>-->
<Grid.RowDefinitions>
<RowDefinition Height="5*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<cv:CarouselView ItemsSource="{Binding Zoos}" x:Name="CarouselImages" >
<cv:CarouselView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Grid.RowSpan="2" Aspect="AspectFill" Source="{Binding ImageUrl}"/>
<StackLayout Grid.Row="1" BackgroundColor="#80000000" Padding="12">
<Label TextColor="White" Text="{Binding Name}" FontSize="16" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</Grid>
</DataTemplate>
</cv:CarouselView.ItemTemplate>
</cv:CarouselView>
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" Margin="20,20,20,0" Grid.Row="2">
<Button Text="Register" BackgroundColor="#3897f0" TextColor="White" HeightRequest="50" VerticalOptions="Start" />
</StackLayout>
</Grid></ContentPage>发布于 2018-05-02 08:07:32
有几件事很突出..。首先,为网格定义3行,但是包含按钮的StackLayout位于Grid.Row="2“中,如果需要位于旋转木马下面,则应该是1。(对可读性而言,最好将Grid.Row="0“放在旋转木马上)
其次,您不需要用StackLayout包装按钮,并将HorizontalOptions放到FillAndExpand中以填充整个网格大小。
https://stackoverflow.com/questions/50129040
复制相似问题