使用XAML制作listview数据模板

时间:2019-02-26 22:01:32

标签: c# xaml xamarin

我正在尝试使用Xamarin中的XAML为我的餐厅应用创建一个列表视图,

enter image description here

问题是我是XAML的新手,只能使它看起来像这样:

enter image description here

如果可以的话,请协助我:)

<?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="App_Name.View.BarPage"
             xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView" >

    <ContentPage.Content>

        <flv:FlowListView x:Name="FlowListViewHk" FlowColumnCount="{Binding ColumnCount}"
                           SeparatorVisibility="Default" HasUnevenRows="True"
                           FlowTappedBackgroundColor="Black" IsGroupingEnabled="True"
                           ItemSelected="UpdateStatus" GroupDisplayBinding="{Binding TableNumber}"
                           FlowItemTapped="UpdateStatus"
                           FlowItemsSource="{Binding Items}" FlowColumnMinWidth="220">

            <flv:FlowListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell Height="40">
                        <StackLayout VerticalOptions="CenterAndExpand"
                       Padding="5"
                       BackgroundColor="Red">
                            <Label Text="{Binding TBlNo}" TextColor="Black" VerticalOptions="Center" FontSize="Large" HorizontalOptions="CenterAndExpand"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </flv:FlowListView.GroupHeaderTemplate>


            <flv:FlowListView.FlowColumnTemplate>
                <DataTemplate>
                    <Grid x:Name="listx">
                        <StackLayout Margin="5" BackgroundColor="Red" >
                            <Grid x:Name="controlGrid">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="25*" />
                                    <RowDefinition Height="25*" />
                                    <RowDefinition Height="25*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="50*" />
                                    <ColumnDefinition Width="50*" />
                                </Grid.ColumnDefinitions>
                                <Label HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" BackgroundColor="Red" TextColor="Black"
                                Text="{Binding TableNumber}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="Large"/>
                                <Label HorizontalOptions="Fill" VerticalOptions="Fill" 
                                XAlign="Center" YAlign="Center" Text="{Binding ItemName}"  Grid.Row="1" Grid.Column="0" TextColor="Black"/>
                                <Label HorizontalOptions="FillAndExpand" VerticalOptions="Fill" 
                                XAlign="Center" YAlign="Center" Text="{Binding OrderedQuantity}"  Grid.Row="1" Grid.Column="1" TextColor="Black"/>
                                <!--<Button Text="{Binding Status}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" TextColor="Black" BackgroundColor="White" Clicked="btnClicked"/>-->
                                <Label HorizontalOptions="FillAndExpand" VerticalOptions="Fill" 
                                XAlign="Center" YAlign="Center" Text="{Binding Status}"  Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" TextColor="Black" BackgroundColor="White"/>
                            </Grid>
                        </StackLayout>
                    </Grid>
                </DataTemplate>
            </flv:FlowListView.FlowColumnTemplate>
        </flv:FlowListView>
    </ContentPage.Content>
</ContentPage>

上面是我的Xaml的代码,以及我如何实现不需要的结果。

0 个答案:

没有答案