xaml - 在 xamarin.forms 中设计图片库

标签 xaml xamarin.forms

我有一个 JSON,其中包含图像缩略图 URL 和一些文本,现在我必须将其呈现为像电话画廊这样的图像画廊。我对网格布局进行了大量研究,但没有找到一种方法来动态创建可以显示图像的固定宽度和高度的网格数量。谁能告诉我设计包含大量图像的画廊类型页面的最佳组件是什么?

最佳答案

您可以使用 this nuget 包并在网格中显示图像。示例代码:

<flv:FlowListView FlowColumnCount="3" SeparatorVisibility="None" HasUnevenRows="false"
FlowItemTappedCommand="{Binding ItemTappedCommand}" 
FlowItemsSource="{Binding PhotosList}" >
            <flv:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <StackLayout>
                        <Image Source="{Binding Image}" HeightRequest="50" WidthRequest="50"/>
                        <Label Text="{Binding Name}" TextColor="Black" FontSize="Medium" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
                    </StackLayout>
                </DataTemplate>
          </flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>

其中,PhotosList 将是您的 URL 和文本列表。

关于xaml - 在 xamarin.forms 中设计图片库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29078468/

相关文章:

xaml - 如何在xaml中添加Event事件处理程序?

c# - 从 iPhone 保存计算机可访问的文件

c# - Xamarin.Forms ListView 中的项目之间的填充

xamarin - 平台上不同的网格大小(高度)

android - Xamarin.Forms 后台/前台服务最佳实践?

c# - 集合值数据绑定(bind)/数据触发器上的 ListView 项不可选择触发器

c# - 消息对话框中的文本输入?内容对话框?

.net - 覆盖 App.xaml 中的标准主题

c# - WPF 红色边框意外地在组合框周围闪烁

c# - 如何处理硬件按钮。在 UWP 中按下后退?