【发布时间】:2022-11-25 08:25:07
【问题描述】:
PeekAreaInsets 是 Thickness 类型,我试图使轮播视图的横向项目具有更小的高度。但似乎声明 PeekAreaInsets="20,100" 不起作用。
此外,我正在尝试在项目的一半背景上声明渐变,但应用不正确。所以我在这里试图实现这个功能感到双重困惑......有没有人遇到过这个问题?谢谢大家
<CarouselView ItemsSource="{Binding ListOfGames}" PeekAreaInsets="20,100" HeightRequest="190" IsSwipeEnabled="True" Loop="True" >
<CarouselView.ItemTemplate>
<DataTemplate>
<Frame Grid.Row="0" CornerRadius="10" Margin="0" Padding="0" HasShadow="False" HeightRequest="190" WidthRequest="340" BackgroundColor="Transparent">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="1" Text="{Binding Campaign}" FontFamily="Lato-Regular" FontSize="21" TextColor="White"/>
<Label Grid.Row="2" Text="{Binding Section}" FontFamily="Lato-Regular" FontSize="13" TextColor="White"/>
</Grid>
<Frame.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStopCollection>
<GradientStop Color="Transparent" Offset="0.5" />
<GradientStop Color="#b3000000" Offset="1.0" />
</GradientStopCollection>
</LinearGradientBrush>
</Frame.Background>
</Frame>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
【问题讨论】:
-
您只想将它应用于布局的一半,但实际上您显然是将它应用于整个布局的框架,对吗?
-
StartPoint=0,0 和 EndPoint=0,1 与 OffSet=0.5 属性相结合表示渐变垂直并从整个帧的 50% 开始,是的。但不知何故渐变不是线性渐变的颜色,它更像是一开始就变成灰色。
-
我认为您误解了这是如何工作的让我添加一个示例
标签: .net xamarin xamarin.forms lineargradientbrush xamarin.forms.carouselview