maui sqlite开发一个商城加购物车的演示(2)

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

二个models


using System;
using System.Collections.ObjectModel;
using System.Runtime.Intrinsics.Arm;
using System.Windows.Input;

namespace ShoppingUI
{
    public class ProductPageViewModel
    {
        public ObservableCollection<Items> Items { get; set; }

        public ObservableCollection<Items> CartItems { get; set; }

        public Items SelectedItem { get; set; }

        public ICommand Itemclick { get; set; }
        public ICommand CartItemclick { get; set; }
        public ProductPageViewModel(INavigation navigation)
        {
            Items = new ObservableCollection<Items>
            {
                new Items
                {
                    Picture="watch.png",
                    Name = "百大非丽",
                    Description="百大非丽说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",
                    Quantity = "1",
                    Price = "99元"
                },
                new Items
                {
                    Picture="divingwatch.png",
                    Name = "电子表",
                    Quantity = "1",
                    Price = "89元",
                    Description="电子表丽说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",
                },
                new Items
                {
                    Picture="dresswatch.png",
                    Name = "小米",
                    Quantity = "1",
                    Price = "85元",
                      Description="小米丽说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",
                },
                new Items
                {
                    Picture="militarywatch.png",
                    Name = "华为电子表",
                    Quantity = "1",
                    Price = "99元",
                     Description="华为电子说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",
                },
                new Items
                {
                    Picture="wristwatch.png",
                    Name = "VIVO电子表",
                    Quantity = "1",
                    Price = "85元",
                     Description="VIVO电子表说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",

                },
                new Items
                {
                    Picture="militarywatch.png",
                    Name = "腕表",
                    Quantity = "1",
                    Price = "99元",
                    Description="腕表电子表说明百大非丽说明百大非丽说明百大非丽说明百大非丽说明",
                }
            };
            BackCommand = new Command(ExecuteBackCommand);
            CartItems = new ObservableCollection<Items> { };
            Itemclick = new Command<Items>(executeitemclickcommand);
            CartItemclick = new Command<Items>(executeCartitemclickcommand);
            this.navigation = navigation;
        }
        private INavigation navigation;

        async void executeitemclickcommand(Items item)
        {
            this.SelectedItem = item;
            await navigation.PushModalAsync(new DetailsPage(this));
        }

        async void executeCartitemclickcommand(Items item)
        {
            this.CartItems.Add(this.SelectedItem);
            await navigation.PushModalAsync(new CartPage(this));

        }

        private async void ExecuteBackCommand()
        {
            await Application.Current.MainPage.Navigation.PopAsync();
        }
        private readonly INavigation _navigation;

        public ICommand BackCommand { get; }
        private async void BackCommandExecute()
        {
            // 使用 Navigation 接口的 PopAsync 方法返回上一页
            await _navigation.PopAsync();
        }
    }
}

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:syncfusion="clr-namespace:Syncfusion.Maui.ListView;assembly=Syncfusion.Maui.ListView"
             x:Class="ShoppingUI.ProductPage"
             Title="商品">
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="返回" Command="{Binding BackCommand}" />
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <Grid RowDefinitions="auto,*" Padding="0,10,0,0" Background="#292B2D">
            <Label Text="商品" TextColor="White" FontSize="30" FontAttributes="Bold" HorizontalTextAlignment="Center" Margin="0,0,0,30"/>
            <BoxView Grid.Row="1" CornerRadius="20,20,0,0" Color="White">
                
            </BoxView>
            <syncfusion:SfListView x:Name="listView" ItemSpacing="5,0,0,0" Grid.Row="1" Margin="0,10,0,0"
                   ItemsSource="{Binding Items}"    ItemSize="120">

            <syncfusion:SfListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,0,0,0" RowDefinitions="*,4" ColumnDefinitions="120,*,*">
                            <Frame HeightRequest="100" WidthRequest="100" HasShadow="False" Grid.Column="0" Grid.RowSpan="2" CornerRadius="10" BackgroundColor="White"  VerticalOptions="CenterAndExpand">
                                <Image Source="{Binding Picture}"  Aspect="AspectFill" />
                            </Frame>
                            <StackLayout Grid.RowSpan="2" Grid.Column="1" VerticalOptions="Center">
                                <Label Text="{Binding Name}"  Padding="10,0,0,10" FontSize="17" FontAttributes="Bold"/>
                                <Label  Text="{Binding Price}" Padding="10,0,0,0" FontAttributes="Bold" FontSize="20" TextColor="#2C363C"/>
                            </StackLayout>
                            <Grid Grid.Column="3" VerticalOptions="Center">
                                <Button  FontSize="13"  Margin="0,0,10,0" BackgroundColor="#2C363C" Text="查看" Command="{Binding Source={x:Reference listView},Path=BindingContext.Itemclick}" CommandParameter="{Binding}" TextColor="White" HorizontalOptions="End" HeightRequest="40" WidthRequest="70"/>
                            </Grid>
                            <Grid Grid.Row="1" Grid.ColumnSpan="3">
                                <Label Background="LightGray" Margin="2" HeightRequest="1"/>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </syncfusion:SfListView.ItemTemplate>
        </syncfusion:SfListView>
        </Grid>
       
    </ContentPage.Content>
</ContentPage>
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

“maui sqlite开发一个商城加购物车的演示(2)” 的相关文章

php怎么将字符串转换为JSON对象数组 - 编程语言

本篇内容介绍了“php怎么将字符串转换为JSON对象数组”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! JSON(JavaScript Ob...

怎么用Python解决Excel问题 - 开发技术

本篇内容介绍了“怎么用Python解决Excel问题”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!「问题说明」这次要处理的excel有两个sheet,要根据其中一个sh...

【docker】使用docker安装宝塔面板

在使用docker安装宝塔面板之前请先确保服务器已经安装并开启了docker 拉取centos基础镜像用容器启动该基础镜像直接在这个容器中部署 1.拉取纯净系统镜像 $ docker pull centos:7.2.1511    2.启动镜像映射主机与容器内8888宝塔面板、88...

定义PHP数组的方式是什么 - 编程语言

这篇文章主要介绍“定义PHP数组的方式是什么”,在日常操作中,相信很多人在定义PHP数组的方式是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”定义PHP数组的方式是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!...

Oracle

select * from v$version;或select * from product_component_version;或select * from v$instance...

Hibernate

异常: org.hibernate.hql.ast.QuerySyntaxException: Path expected for join HQL是面向对象的,所以join的条件是反映在对象的关系中的,所以,你在用join的时候,无论是left join还是right join...