I have the following peices of code:
List<String> AdminLocation= new List<String>();
AdminLocation.Add("Location1");
AdminLocation.Add("Location2");
AdminLocation.Add("Location3");
AdminLocation.Cast<string>().ToList()
ContactLocations = Locations
.Where(l => l.Active == "Y").OrderBy(l => l.Name)
.Select(l => new Location { DbLocation = l, IsChecked = false })
.ToList();
public class Location {
public db.Location DbLocation { get; set; }
public Boolean IsChecked { get; set; }
public Boolean IsEnabled { get; set; }
}
In my WPF XAML I have a Listbox with checkboxes. Currently ContactLocations returns all the locations. I'd like to add the AdminLocation list to the mix and set the IsEnabled flag to false for all the locations that are NOT found in AdminLocation but are in ContactLocations.
For example ContactLocations could include:
Location1 Location2 Location3 Location4 Location5
So what I'd like to see is Location4 and Location5 IsEnabled = false and all the other items would be set to true.
I have code that will eliminate Location4 and Location5 from the list but I really want those to just have a different IsEnabled flag value.
ContactLocations = Locations
.Where(l => l.Active == "Y").OrderBy(l => l.Name)
.Select(l => new Location { DbLocation = l,
IsChecked = false,
IsEnabled = true [if contains in AdminLocation] else false })
.ToList();