public int CountState(ViewState flag) { int count = 0; foreach (var view in this.Views) { if (flag.HasFlag(view.State) == true) { count++; } } return(count); }