info页面添加下滑刷新

This commit is contained in:
Administrator committed 2026-05-12 02:28:58 +08:00
commit 8e4af75d05
3 files changed
+14 -26

No files matched your search

+9 -19
View File
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
using SunlightAggregationTerminal.Class;
using SunlightAggregationTerminal.Models;
using System.Collections.ObjectModel;
@@ -12,10 +13,11 @@ public partial class InfoPage : ContentPage
public static string? _Name, _State, _MachineName, _Machine, _Information, _Model,
_Type, _ModelA, _ModelB, _ModelC, _ModelD, _ModelE, _ModelF;
public InfoPage()
{
InitializeComponent();
CardCollectionView.ItemsSource = InfoItems;
// 注册订阅一个不携带数据的消息(使用 object 作为泛型)
WeakReferenceMessenger.Default.Register<object>(this, (r, m) =>
@@ -23,6 +25,10 @@ public partial class InfoPage : ContentPage
// 收到信号,直接触发函数
HandleUITrigger();
});
//注册当前页面的下滑刷新
myRefreshView_.Refreshing += (sender, e) => {
TcpServer.TcpTransmit("{\"Command\":\"Info\"}");
myRefreshView_.IsRefreshing = false; };
}
private void HandleUITrigger()
{
@@ -61,24 +67,8 @@ public partial class InfoPage : ContentPage
});
}
InfoItems.Add(new InfoItem
{
Name = _Name,
State = _State,
MachineName = _MachineName,
Machine = _Machine,
Information = _Information,
Type = _Type,
Model = _Model,
ModelA = _ModelA,
ModelB = _ModelB,
ModelC = _ModelC,
ModelD = _ModelD,
ModelE = _ModelE,
ModelF = _ModelF
});
CardCollectionView.ItemsSource = InfoItems;
myRefreshView_.IsRefreshing = false;
}
~InfoPage()//关闭时注销消息