我這樣做的代碼,而不是在XAML中,我發現它更容易申請,但它應該是類似的東西(也可能有比我更好的辦法)。
我在FlowListView控件上將'HasUnevenRows'屬性設置爲true。
Flow = new FlowListView()
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
FlowColumnCount = 3,
FlowColumnTemplate = new DataTemplate(typeof(FlowCellImage)),
FlowTappedBackgroundDelay = 250,
FlowTappedBackgroundColor = Color.Gray,
SeparatorVisibility = SeparatorVisibility.Default,
IsPullToRefreshEnabled = true,
HasUnevenRows = true,
//Margin = thickness
};
然後在圖片我設置的「HeightRequest」屬性是「Application.Current.MainPage.Width/3」作爲我行曾在這3張照片。
public class FlowCellImage : FlowViewCell
{
private Image ImgPost;
public FlowCellImage()
{
ImgPost = new Image
{
Aspect = Aspect.AspectFill
};
ImgPost.SetBinding(Image.SourceProperty, "ThumbnailUrl");
HeightRequest = Application.Current.MainPage.Width/3;
Content = ImgPost;
}
}
我面臨同樣的問題。你解決了這個問題嗎? – AbsoluteSith