EBDN - Community - Question & Answers

  Monday, 04 March 2019
  4 Replies
  1.2K Visits
0
Votes
Undo
I have a problem with my macro, I want to call a variable from a different class but it does not pass the value to the other class that I want to use.

Below is the code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Aucotec.EngineeringBase.Client.Runtime;

namespace TokenLicenseUsageReport
{

public class VmUserDatGrid1 : Helpers.VmBase //this is the class1
{
public UserDatGrid userGrid;
public Application myApplication;
public static HashSet<string> Debug { get; set; } //I have used as static so that I can use the value in other classes
public List<VmMainWindow.GroupFile> groupFiles;

public VmUserDatGrid1(UserDatGrid userGrid, Application myApplication, HashSet<string> debug, List<VmMainWindow.GroupFile> groupFiles)
{

Debug = debug;
this.myApplication = myApplication;
this.userGrid = userGrid;
this.groupFiles = groupFiles;


foreach (var item in debug) //debug is a collection of names. When I run it here, it shows the all the names from the collections

{
System.Windows.MessageBox.Show(item):
}

}

public class VmUserDatGrid : Helpers.VmBase //and this is the class2
{
public ICollectionView Customers { get; set; }
public ICollectionView GroupedCustomers { get; set; }

public VmUserDatGrid()
{
foreach (var item in Debug) // but when I run it here, it says that the Debug collection is null
{
System.Windows.MessageBox.Show(item):
}

var _customers = new List<Customer>
{
new Customer
{
Member = "Christian",
Group = Gender.Male,

}
};

Customers = CollectionViewSource.GetDefaultView(_customers);

GroupedCustomers = new ListCollectionView(_customers);
GroupedCustomers.GroupDescriptions.Add(new PropertyGroupDescription("Gender";));
}
}
}
}

I am not sure why it is showing null even after I used static, It will be helpful if someone could help me to solve this problem.

Thank you.