如何在 ListView 中添加多个框架 XAML
How to add several Frame within a ListView XAML
我想添加几个如下图所示的帧:
问题是这些在 <ListView>
内,它不允许我在 <View>
标签内添加多个
当我添加第二个时,出现以下错误:
The property 'View' is set more than once.
我附上了我的 LIstView 结构的屏幕截图以获取更多详细信息及其各自的代码。
<ListView
ItemsSource="{Binding Reportes}"
SelectionMode="None"
Margin="0,0,10,0"
HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame
CornerRadius="15"
HasShadow="True"
Padding="5"
BackgroundColor="{StaticResource das.color.estado_primary}">
<StackLayout
Orientation="Horizontal"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Image
Source="barrascf"
HeightRequest="80"
WidthRequest="80"
Opacity="1">
</Image>
<StackLayout
Orientation="Vertical"
HorizontalOptions="EndAndExpand"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Label
Text="{Binding ArticulosTotales}"
TextColor="White">
</Label>
<Label
Text="ARTICULOS TOTALES"
TextColor="White">
</Label>
</StackLayout>
</StackLayout>
</Frame>
<Frame
CornerRadius="15"
HasShadow="True"
Padding="5"
BackgroundColor="{StaticResource das.color.estado_primary}">
<StackLayout
Orientation="Horizontal"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Image
Source="barrascf"
HeightRequest="80"
WidthRequest="80"
Opacity="1">
</Image>
<StackLayout
Orientation="Vertical"
HorizontalOptions="EndAndExpand"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Label
Text="{Binding ArticulosTotales}"
TextColor="White">
</Label>
<Label
Text="ARTICULOS TOTALES"
TextColor="White">
</Label>
</StackLayout>
</StackLayout>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我做错了什么?我应该如何构建我的 XAML 代码?对我有什么帮助吗?
任何时候您需要将多个视图添加到只接受单个子项的控件中,您可以通过将它们包装在布局容器(Stack、Grid 等)中来实现
<ViewCell>
<StackLayout>
<Frame/>
<Frame/>
<Frame/>
</StackLayout>
</ViewCell>
我想添加几个如下图所示的帧:
问题是这些在 <ListView>
内,它不允许我在 <View>
标签内添加多个
当我添加第二个时,出现以下错误:
The property 'View' is set more than once.
我附上了我的 LIstView 结构的屏幕截图以获取更多详细信息及其各自的代码。
<ListView
ItemsSource="{Binding Reportes}"
SelectionMode="None"
Margin="0,0,10,0"
HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame
CornerRadius="15"
HasShadow="True"
Padding="5"
BackgroundColor="{StaticResource das.color.estado_primary}">
<StackLayout
Orientation="Horizontal"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Image
Source="barrascf"
HeightRequest="80"
WidthRequest="80"
Opacity="1">
</Image>
<StackLayout
Orientation="Vertical"
HorizontalOptions="EndAndExpand"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Label
Text="{Binding ArticulosTotales}"
TextColor="White">
</Label>
<Label
Text="ARTICULOS TOTALES"
TextColor="White">
</Label>
</StackLayout>
</StackLayout>
</Frame>
<Frame
CornerRadius="15"
HasShadow="True"
Padding="5"
BackgroundColor="{StaticResource das.color.estado_primary}">
<StackLayout
Orientation="Horizontal"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Image
Source="barrascf"
HeightRequest="80"
WidthRequest="80"
Opacity="1">
</Image>
<StackLayout
Orientation="Vertical"
HorizontalOptions="EndAndExpand"
BackgroundColor="{StaticResource das.color.estado_primary}">
<Label
Text="{Binding ArticulosTotales}"
TextColor="White">
</Label>
<Label
Text="ARTICULOS TOTALES"
TextColor="White">
</Label>
</StackLayout>
</StackLayout>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我做错了什么?我应该如何构建我的 XAML 代码?对我有什么帮助吗?
任何时候您需要将多个视图添加到只接受单个子项的控件中,您可以通过将它们包装在布局容器(Stack、Grid 等)中来实现
<ViewCell>
<StackLayout>
<Frame/>
<Frame/>
<Frame/>
</StackLayout>
</ViewCell>