maui中实现加载更多 RefreshView跟ListView 跳转到详情页 传参(3)

效果如图

在这里插入图片描述
这里的很多数据是通过传参过来的的。

代码

例表页加入跳转功能:

  <ListView ItemsSource="{Binding Items}" ItemAppearing="OnItemAppearing" ItemTapped="OnItemTapped"   RowHeight="70" Margin="20">
后台加入 
 async void OnItemTapped(object sender, ItemTappedEventArgs e)
 {
   
     if (e.Item is Product tappedProduct)
     {
   
  Console.WriteLine($"Added item: Id={
     tappedProduct.Id}, ImageSource={
     tappedProduct.ImageSource}, ProductName={
     tappedProduct.ProductName}, Price={
     tappedProduct.Price}, Details={
     tappedProduct.Details} ImageSource={
     tappedProduct.ImageSource}");
         await Shell.Current.GoToAsync($"DetailsPage?id={
     tappedProduct.Id}&id={
     tappedProduct.ImageSource}&name={
     tappedProduct.ProductName}&price={
     tappedProduct.Price}&details={
     tappedProduct.Details}&img={
     tappedProduct.ImageSource}");

     }
 }

详情页:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="fenye.Views.DetailsPage"
             Title="{Binding Name}">
    <ScrollView>
        <Grid RowDefinitions="Auto,Auto,*">
            <BoxView
                BackgroundColor="{StaticResource Primary}"
                Grid.RowSpan="2"
                HorizontalOptions="Fill"
                VerticalOptions="Fill"/>

            <Border StrokeShape="RoundRectangle 80"
                    Stroke="White"
                    StrokeThickness="6"
                    HeightRequest="160"
                    WidthRequest="160"
                    Margin="0,8,0,0"
                    HorizontalOptions="Center"
                    VerticalOptions="Center">
                <Image Aspect="AspectFill"
                        HeightRequest="160"
                        HorizontalOptions="Center"
                        VerticalOptions="Center"

                        WidthRequest="160">
                    <Image.Source>
                        <FileImageSource File="{Binding Img}" />
                    </Image.Source>
                </Image>
            </Border>

            <Label Style="{StaticResource LargeLabel}" 
                   Grid.Row="1"
                   TextColor="White"
                   FontAttributes="Bold"
                   Text="{Binding Price}" 
                   HorizontalOptions="Center"
                   Margin="0,0,0,8"/>

            <VerticalStackLayout Grid.Row="2" Padding="10" Spacing="10">
                <Label Text="{Binding Details}" />
            </VerticalStackLayout>
        </Grid>
    </ScrollView>
</ContentPage>
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Xml.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using fenye.Model;

namespace fenye.Views
{
   


    [QueryProperty(nameof(Id), "id")]
    [QueryProperty(nameof(Name), "name")]
    [QueryProperty(nameof(Img), "img")]
    [QueryProperty(nameof(Price), "price")]
    public partial class DetailsPage : ContentPage, INotifyPropertyChanged
    {
   

        // public string Details = "已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用";
        private string details = "已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用";
        public string Details
        {
   
            get {
    return details; }
            set
            {
   
                details = value;
                OnPropertyChanged();
            }
        }

        private string name;
        public string Name
        {
   
            get {
    return name; }
            set
            {
   
                name = value;
                OnPropertyChanged();
            }
        }

        private string img;
        public string Img
        {
   
            get {
    return img; }
            set
            {
   
                img = value;
                OnPropertyChanged();
            }
        }


        private string price;
        public string Price
        {
   
            get {
    return price; }
            set
            {
   
                price = value;
                OnPropertyChanged();
            }
        }



        public DetailsPage()
        {
   
            InitializeComponent();
            BindingContext = this;
        }

    }
}

相关推荐

  1. vue3路由传递参数: params接收不

    2023-12-17 07:32:03       36 阅读
  2. vue3路由

    2023-12-17 07:32:03       57 阅读
  3. vue的

    2023-12-17 07:32:03       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-17 07:32:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-17 07:32:03       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-17 07:32:03       82 阅读
  4. Python语言-面向对象

    2023-12-17 07:32:03       91 阅读

热门阅读

  1. 【人生感悟】涅槃重生

    2023-12-17 07:32:03       67 阅读
  2. 实现两张图片的接缝线拼接

    2023-12-17 07:32:03       66 阅读
  3. Webpack5

    2023-12-17 07:32:03       63 阅读
  4. 打包速度优化

    2023-12-17 07:32:03       56 阅读
  5. Python学习之复习MySQL-Day4(DCL)

    2023-12-17 07:32:03       63 阅读
  6. 算法工程师-机器学习面试题总结(7)

    2023-12-17 07:32:03       44 阅读
  7. 2023-12-17 创业日记-创业方向的选择

    2023-12-17 07:32:03       55 阅读
  8. 神经网络基础

    2023-12-17 07:32:03       61 阅读
  9. CDN加速在游戏服务商中的关键作用

    2023-12-17 07:32:03       51 阅读
  10. 《C++20设计模式》---桥接模式学习笔记

    2023-12-17 07:32:03       75 阅读
  11. Ansible如何处理play错误的?Ansible角色?

    2023-12-17 07:32:03       65 阅读