С .net maui, при создании CollectionView из списка, как мне получить доступ к другому списку, чтобы получить детали на оC#

Место общения программистов C#
Ответить
Гость
 С .net maui, при создании CollectionView из списка, как мне получить доступ к другому списку, чтобы получить детали на о

Сообщение Гость »


I'm still fairly new to xaml and .net maui but I don't really know what search terms to even use. I want to list today's task notifications in xaml with a collection view. I want this list, when displaying in xaml collection view, to pull details from another list using the TaskID as an identifier key.
For example, roughly:

Код: Выделить всё

    class Notification:
int Id;
int TaskID;
int Title;
DateTime NotificationTime;

class Task:
int Id;
string Name;
string Details;

Код: Выделить всё

    UpcomingNotificationsViewModel:

List NotificationsList { get; set; }
List TasksList { get; set; }

async void LoadData()
{
var result = from s in NotificationsList
where s.NotificationTime.Date == today
group s by s.NotificationTime into g
select new GroupedNotification{ NotificationTime = g.Key, Notification = g.ToList() };

GroupedNotifications = result;
}

public class GroupedNotification
{
public DateTime NotifyTime { get; set; }
public List Notification { get; set; }
}
In the XAML, while iterating over CollectionView of Notifications, I want to also pull data from the TasksList like the Task.Name, Task.Details, and so on.

Код: Выделить всё

    















//this label below, how can I link it to TaskList and get details based on TaskID from this Notification List?











`
I tried several different iterations of this code, I tried searching for the past three hours, tried asking ChatGPT and Gemini but I cannot find what I'm looking for. I need someone to point me in the correct direction.


Источник: https://stackoverflow.com/questions/781 ... ccess-anot
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»