public void UpdateSubcatgoriesVisible(int?changedCategoryId = null, bool?isSelected = null) { if (changedCategoryId != null && isSelected != null) { } else { var selected = SelectedCategories.ToList(); foreach (var subCategory in PinSubCategories) { if (subCategory.ParentId != null && selected.Contains(subCategory.ParentId.Value)) { subCategory.IsVisible = true; } else { subCategory.IsVisible = subCategory.ItemSelected = false; } } } UpdatePinsVisible(); }