【问题标题】:How to make a Card Style ListView In Xamarin Forms如何在 Xamarin 表单中制作卡片样式 ListView
【发布时间】:2017-06-13 22:57:51
【问题描述】:

我正在尝试基于 ahaliav fox 的 xaml 示例 here 在 Xamarin 表单中制作基于卡片的 listView 但是我没有得到任何接近他得到的东西我只有一个文本标签需要在卡片中显示

这是我的 xaml 代码:

    <?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="WebSearch.CountySelect" BackgroundColor="Gray">
  <ListView x:Name="listView">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ViewCell>

          <Frame Padding="0,0,0,3">
            <Frame.Content>
              <Frame Padding="15,15,15,15"   OutlineColor="Gray" BackgroundColor="White">
                <Frame.Content>
                  <StackLayout Padding="20,0,0,0"  Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
                    <Label Text="{Binding Name}"
                           FontFamily="OpenSans-Light"
                           FontSize="9"
                           TextColor="#69add1"/>
                  </StackLayout>

                </Frame.Content>

              </Frame>
            </Frame.Content>

          </Frame>

        </ViewCell>
      </DataTemplate>
    </ListView.ItemTemplate>
    </ListView>
</ContentPage>

编辑:我使用 Frame 使 ListView 项目类似于卡片,但是标签上的文本会截断一半,除非我将文本大小设置为 9 或更低,这对于修复此错误有什么办法吗?

我已更新我的代码以反映我遇到的新问题

任何帮助都会很棒!

【问题讨论】:

  • 您的问题是什么?你实际上并没有问过任何人,也没有清楚地说明你遇到了什么问题。
  • 我更新了我的问题,使其与我的问题相似,请查看 :)
  • Label 中的名称有多长?还有你测试的设备有多大?您是否尝试过删除一些 Padding 以查看是否有帮助?或者尝试将Label.LineBreakMode 设置为WordWrap

标签: c# xaml listview xamarin


【解决方案1】:

尝试将ListView.HasUnevenRows 属性设置为true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    • 2018-05-30
    • 2016-10-31
    • 2018-03-11
    • 2021-01-16
    • 2021-11-03
    • 2020-10-25
    相关资源
    最近更新 更多