I have created a list within this class called myVar...
class FailedIgnoredRetrieved
{
public static async Task FailedIgnoredRetrievedAndShow(ListView commentLabel)
{
void AllEventsComment(string comment)
{
if (commentLabel != null)
{
commentLabel.ItemsSource += comment; //+ "\n";
}
}
AllEventsComment("...");
var api = new ApiClient();
var retrieved = ApiToken.Load();
if (retrieved == null)
{
AllEventsComment("Failed, not signed in");
App.SwitchIcon(NotifyIcons.GreyIcon);
}
else
{
var result = await api.GetAllEventsAsync(retrieved.Token);
if (result.IsSuccessful)
{
List<string> myVar = new List<string>();
void AddToList(string v)
{
myVar.Add(v);
}
foreach (var eventsText in result.Events)
if (eventsText.EventStatus == 1)
{
AddToList($"Red {eventsText.CheckId}");
}
else if (eventsText.EventStatus == 0)
{
AddToList($"Orange {eventsText.CheckId}");
}
}
}
}
}
}
I now want to use myVar List in FailedIgnoredWindow.xaml.cs to bind to for a ListView in FailedIgnoredWindow.xaml I'm struggling to understand how to set it as the ListView.ItemSource = i.e. how do I access the list in the other class?
public partial class FailedIgnoredWindow : Window
{
public FailedIgnoredWindow()
{
InitializeComponent();
FailedIgnoredDialogue.ItemsSource =
}
private async void AllEvents_Click(object sender, RoutedEventArgs e)
{
AllEventsWindow win2 = new AllEventsWindow();
this.Visibility = Visibility.Hidden;
win2.WindowStartupLocation = 0;
//win2.Left = 0;
//win2.Top = 0;
win2.Show();
await AllEventsRetrieved.AllEventsRetrievedAndShowCount(win2.AllEventsDialogue);
}
}
I've tried to create a seperate class with the properties but I'm struggling to fully understand what I need to do.