I have a dropdownbox, ActiviteitAardItems
, where ActiviteitAard
items can be checked (checkbox). If one (or more) are checked the property Opacity will be changed, and the code beneath will be executed. The Tijdblok
mentioned below also has a property Activiteit
and ActiviteitAard
.
public double Opacity
{
get
{
if (Planning.ActiviteitAardItems.Where(aa => aa.IsChecked == true).Count() > 0)
{
if (this.Tijdblokken.Where(t => t.Activiteit != null && t.Activiteit.ActiviteitAard != null).Count() > 0)
{
Tijdblok tijdblok;
var tijdblokken = new List<Tijdblok>();
foreach (var item in Planning.ActiviteitAardItems.Where(aa => aa.IsChecked == true))
{
tijdblok = this.Tijdblokken.Where(t => t.Activiteit != null && t.Activiteit.ActiviteitAard != null && t.Activiteit.ActiviteitAard.Code == item.Code).FirstOrDefault();
if (tijdblok != null)
tijdblokken.Add(tijdblok);
}
tijdblok = tijdblokken.OrderByDescending(tb => tb.Activiteit.RoosterKleurPrioriteit).FirstOrDefault();
if (tijdblok != null && tijdblok.Activiteit != null && tijdblok.Activiteit.ActiviteitAard != null)
{
if (Planning.ActiviteitAardItems.Where(aa => aa.IsChecked).Select(x => x.Code).Contains(tijdblok.Activiteit.ActiviteitAard.Code))
{
return 1.0;
}
else
{
return 0.1;
}
}
else
{
return 0.1;
}
}
else
{
return 0.1;
}
}
return 1.0;
}
}