【发布时间】:2017-04-05 17:04:07
【问题描述】:
我正在尝试使用 Xamarin Forms 制作一个应用程序,该应用程序有一个菜单(使用 ListView),并且在每道菜附近,都有一个步进器和价格。
最后,当用户完成决定他想要哪些餐点以及每餐多少餐时,我想计算总价格,但我不知道该怎么做。
<?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="Eba_face.MenuPage"
Title="Menu">
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView x:Name="listview"
HasUnevenRows="True"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="5">
<StackLayout Orientation="Vertical">
<Image x:Name="image" Source="{Binding Image}" WidthRequest="75" HeightRequest="75"/>
<Label Text="{Binding Name}" FontAttributes="Bold"/>
</StackLayout>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Weight, StringFormat='Weight {0}'}"/>
<Label Text="{Binding Price}" TextColor="Gray"/>
</StackLayout>
<StackLayout HorizontalOptions="EndAndExpand">
<Stepper x:Name="stepper" ValueChanged="Handle_StepperValueChanged"/>
<Label Text="{Binding Source={x:Reference stepper}, Path=Value}" HorizontalOptions="Center"/>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout Orientation="Vertical" VerticalOptions="End" HorizontalOptions="Center">
<Label x:Name="totalPriceLabel" Text="Total Price:" HorizontalOptions="Center"/>
<Button Text="Proceed to finish the order" />
</StackLayout>
</Grid>
</ContentPage>
【问题讨论】:
标签: xaml listview xamarin xamarin.forms uistepper