问题描述
我试图基于ahaliav fox的xaml示例在Xamarin Forms中创建基于卡的listView ,但是我没有得到他所得到的东西,我只能在卡中显示一个文本标签, /p>
这是我的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>
我通过使用框架使ListView项目类似于卡片,但是标签上的文本会截断一半,除非我将文本大小设置为9或更小,否则将无法解决此错误.
我已更新代码以反映我遇到的新问题
任何帮助都将是惊人的!
尝试将ListView.HasUnevenRows
属性设置为true
I am trying to make a card based listView In Xamarin Forms based off of ahaliav fox's xaml example here however I am not getting anywhere near what he got I only have one text label that I need to display in the card
heres my xaml code:
<?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>
EDIT: I got the ListView item to resemble a card by using a Frame however The text on the label cuts off half way unless I make the text size 9 or lower that's way to small any way to fix this bug?
I have updated my code to reflect the new issue i'm having
any help would be amazing!
Try setting the ListView.HasUnevenRows
property to true
这篇关于如何在Xamarin表单中制作卡片样式ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!