简体   繁体   English

Xamarin 表单列表视图设计

[英]Xamarin Forms list view design

How could I achieve the following , it is a list of many items .我怎样才能实现以下目标,它是一个包含许多项目的列表。 but the challenge is to add each item into that buble with the following design.但挑战在于使用以下设计将每个项目添加到该气泡中。

Open to any ideas对任何想法持开放态度

在此处输入图片说明

As Jason said, FlexLayout is a good way.正如 Jason 所说,FlexLayout 是一种很好的方式。 And if you want to add rounded corners to a button, you could use BorderRadius property.如果你想给按钮添加圆角,你可以使用 BorderRadius 属性。

Xaml: Xml:

<ContentPage.Resources>
    <Style TargetType="FlexLayout">
        <Setter Property="AlignItems" Value="Start" />
        <Setter Property="Direction" Value="Row" />
        <Setter Property="Wrap" Value="Wrap" />
    </Style>
    <Style TargetType="Button">
        <Setter Property="BackgroundColor" Value="Blue" />
        <Setter Property="TextColor" Value="White" />
        <Setter Property="Margin" Value="5" />
    </Style>
</ContentPage.Resources>

<FlexLayout AlignContent="Start">
    <Button BorderRadius="25" Text="WIFI" />
    <Button BorderRadius="25" Text="PROJECTOR" />
    <Button BorderRadius="25" Text="APPLE TV" />
    <Button BorderRadius="25" Text="COUCH" />
    <Button BorderRadius="25" Text="WHITEBOARD" />
    <Button BorderRadius="25" Text="CONFERENCE BRIDGE" />
</FlexLayout>

在此处输入图片说明

Updated:更新:

Xaml: Xml:

  <ContentPage.Resources>
    <Style TargetType="FlexLayout">
        <Setter Property="AlignItems" Value="Start" />
        <Setter Property="Direction" Value="Row" />
        <Setter Property="Wrap" Value="Wrap" />
        <Setter Property="AlignContent" Value="Start" />
    </Style>
    <Style TargetType="Button">
        <Setter Property="BackgroundColor" Value="Blue" />
        <Setter Property="TextColor" Value="White" />
        <Setter Property="Margin" Value="5" />
    </Style>
</ContentPage.Resources> 
<FlexLayout BindableLayout.ItemsSource="{Binding List}">
    <BindableLayout.ItemTemplate>
        <DataTemplate>
            <Button BorderRadius="25" Text="{Binding Value}" />
        </DataTemplate>
    </BindableLayout.ItemTemplate>
</FlexLayout>

xaml.cs文件

public partial class MainPage : ContentPage
{

    public List<Values> List { get; set; }
    public MainPage()
    {
        InitializeComponent();

        List = new List<Values>()
        {
             new Values(){ Value="WIFI"},
             new Values(){ Value="PROJECTOR"},
             new Values(){ Value="APPLE TV"},
             new Values(){ Value="COUCH"},
             new Values(){ Value="WHITEBOARD"},
             new Values(){ Value="CONFERENCE BRIDGE"},
        };
        BindingContext = this;

    }
}
public class Values
{
    public string Value { get; set; }
}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM