Xamarin.forms 在列表视图中包含卡片/框架的页面(X.Forms 4.6+;)
我有一个关于X表格的问题。有人知道我如何用X.Forms构建这样一个页面吗 页面流程: 用户必须能够创建注释和/或进行更改。我希望将这些注释一个接一个地显示(最好是在可滚动的列表视图中) 下面是我的代码实现,它并不是很好地工作Xamarin.forms 在列表视图中包含卡片/框架的页面(X.Forms 4.6+;),xamarin.forms,cardview,absolutelayout,content-pages,Xamarin.forms,Cardview,Absolutelayout,Content Pages,我有一个关于X表格的问题。有人知道我如何用X.Forms构建这样一个页面吗 页面流程: 用户必须能够创建注释和/或进行更改。我希望将这些注释一个接一个地显示(最好是在可滚动的列表视图中) 下面是我的代码实现,它并不是很好地工作 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/wi
<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>
单声道
单机器人
单触式
结果如下:
GridView?创建一个与图像中的模板相似的ViewCell。您应该使用stacklayout或grid在框架内布局视图。@JackHua MSFT您有任何示例(代码)吗?谢谢。这就是我需要的。我认为用网格代替堆栈布局是很有用的,这样就可以在性能方面很好地工作。