这是我的 XAML:
<ContentPage.Content>
<StackLayout>
<CollectionView ItemsSource="{Binding GalleryList}" x:Name="cv" SelectionMode="Single" SelectionChanged="CollectionView_SelectionChanged">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="1" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<ContentView Padding="5">
<forms:Frame2 CornerRadius="8"
HasShadow="True"
ShadowRadius="5"
ShadowColor="LightGray"
Padding="0"
Margin="5"
MinimumHeightRequest="160">
<Grid Padding="0" Margin="0" ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<forms:Frame2 CornerRadius="8"
Padding="0"
Margin="0"
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="5"
IsClippedToBounds="true"
BackgroundColor="#EEEEEE">
<ffimageloading:CachedImage Source="{Binding BgImg}" Margin="0" CacheDuration="10" Aspect="AspectFill" Opacity="0.5" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="5">
<ffimageloading:CachedImage.Transformations>
<fftransformations:BlurredTransformation Radius="3"></fftransformations:BlurredTransformation>
</ffimageloading:CachedImage.Transformations>
</ffimageloading:CachedImage>
</forms:Frame2>
<Label Padding="3" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Text="{Binding GalName}" FontSize="Subtitle"></Label>
<Label Padding="5" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Text="Photographer: " FontSize="Small" ></Label>
<Label Padding="3" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding PhName}" FontSize="Default" ></Label>
<Label Padding="5" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Text="Code: " FontSize="Small" ></Label>
<Label Padding="3" x:Name="PhotographerCode" Grid.Row="4" Grid.Column="1" Text="{Binding PhCode}" FontSize="Small" ></Label>
<Label Padding="3" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Text="{Binding GalCode}" FontSize="Small"></Label>
<Button Padding="10" Margin="3" Grid.Row="1" CornerRadius="8" Grid.Column="3" Grid.RowSpan="2" Text="X" FontSize="Default" TextColor="White" Clicked="Button_Clicked" ClassId="{Binding GalCode}" BackgroundColor="DimGray" BorderColor="black" ></Button>
</Grid>
</forms:Frame2>
</ContentView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage.Content>
对于 Frame2,我有MinimumHeightRequest
160 个,因为标签可以是多行的。我希望我的框架尽可能小,但要根据其内容进行扩展。目前它正在工作,但它也在扩展,而不是我用作背景的图像。我希望它仅基于内容而不是图像进行扩展。如何才能做到这一点?
谢谢