You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
using Microsoft.Maui.Controls.Shapes;
|
|
using SunlightAggregationTerminal.Models;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace SunlightAggregationTerminal.NotificationView;
|
|
|
|
public partial class SystemPage : ContentPage
|
|
{
|
|
public ObservableCollection<NotificationItem> SystemItems { get; set; } = new();
|
|
public SystemPage()
|
|
{
|
|
InitializeComponent();
|
|
this.BindingContext = this;
|
|
LoadData(); // 加载数据
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
// 假设这是你获取数据的地方
|
|
var allData = DataService._NotificationData;
|
|
if (allData != null)
|
|
{
|
|
// 清空旧数据
|
|
SystemItems.Clear();
|
|
|
|
// 按时间倒序,并只取最新的 N 条(例如 50 条)
|
|
var itemsToShow = allData.OrderByDescending(x => x.Time).Take(50).Where(x => x.Type == MsgType.System);
|
|
|
|
// 将数据添加到集合中,UI 会自动更新
|
|
foreach (var item in itemsToShow)
|
|
{
|
|
SystemItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CardCollectionView_RemainingItemsThresholdReached(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
}
|