列表视图中带有卡片/框架的页面(X.Forms 4.6+) [英] Page with cards/frames in a listview (X.Forms 4.6+)

查看:28
本文介绍了列表视图中带有卡片/框架的页面(X.Forms 4.6+)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 X.Forms 的问题.有谁知道我如何在 X.Forms 中构建这样的页面?

I had a question about X.Forms. Does anyone know how I can build such a page in X.Forms?

页面流程:用户必须能够创建注释和/或进行更改.我想将这些笔记显示在另一个下方(最好在可滚动列表视图中).

Flow of the page: The user must be able to create a note and/or make changes. I want to display these notes one below the other (preferably in a scrollable list view).

这里是我的代码实现,但效果不佳.

Here is my code implementation that isn't really working fine.

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Xamarin.Forms.TestPage">
    <ContentPage.Content>
        <AbsoluteLayout BackgroundColor="LightGray" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
            <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Blue"  AbsoluteLayout.LayoutBounds="1,0,1,0.1" AbsoluteLayout.LayoutFlags="All"  />
            <StackLayout AbsoluteLayout.LayoutBounds="1,1,1,0.9" AbsoluteLayout.LayoutFlags="All" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="LightGray"/>
            <ListView>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Frame>
                                <Editor></Editor>
                                <Button x:Name="CreateOrChangeButton" Text="Create/Change" Clicked=""></Button>
                                <Button x:Name="DeleteButton" Text="Delete" Clicked=""></Button>
                            </Frame>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </AbsoluteLayout>
    </ContentPage.Content>
</ContentPage>

推荐答案

应该是这样的:

<ListView RowHeight="300" SeparatorVisibility="None" BackgroundColor="White">

    <ListView.ItemsSource>
        <x:Array Type="{x:Type x:String}">
            <x:String>mono</x:String>
            <x:String>monodroid</x:String>
            <x:String>monotouch</x:String>
        </x:Array>
    </ListView.ItemsSource>

    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout>
                    <Frame Margin="40" BackgroundColor="Yellow" HeightRequest="220">

                        <StackLayout>
                            <Editor Text="test" HeightRequest="150"></Editor>

                            <StackLayout Orientation="Horizontal">

                                <Button x:Name="CreateOrChangeButton" Text="Create/Change" TextColor="Black" HorizontalOptions="FillAndExpand"></Button>
                                <Button x:Name="DeleteButton" Text="Delete" TextColor="Black" BackgroundColor="Brown" HorizontalOptions="FillAndExpand"></Button>

                            </StackLayout>
                        </StackLayout>
                    </Frame>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

结果如下:

这篇关于列表视图中带有卡片/框架的页面(X.Forms 4.6+)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆