整合管理器应用端(MAUI跨平台)
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.

43 lines
1.2 KiB

using Microsoft.Maui.Controls.Shapes;
using SunlightAggregationTerminal.Models;
using System.Collections.ObjectModel;
using System.Data;
namespace SunlightAggregationTerminal.NotificationView;
public partial class NoticePage : ContentPage
{
public ObservableCollection<NotificationItem> NoticeItems { get; set; } = new();
public NoticePage()
{
InitializeComponent();
this.BindingContext = this;
LoadData(); // 加载数据
}
private void LoadData()
{
// 假设这是你获取数据的地方
var allData = DataService._NotificationData;
if (allData != null)
{
// 清空旧数据
NoticeItems.Clear();
// 按时间倒序,并只取最新的 N 条(例如 50 条)
var itemsToShow = allData.OrderByDescending(x => x.Time).Take(50).Where(x => x.Type == MsgType.Notice);
// 将数据添加到集合中,UI 会自动更新
foreach (var item in itemsToShow)
{
NoticeItems.Add(item);
}
}
}
private void CardCollectionView_RemainingItemsThresholdReached(object sender, EventArgs e)
{
}
}