bool?Determine(CheckableSystemObject Root) { //Whether or not all children and all children's children have the same value var Uniform = true; //If uniform, the value var Result = default(bool?); var j = false; foreach (var i in Root.Children) { //Get first child's state if (j == false) { Result = i.IsChecked; j = true; } //If the previous child's state is not equal to the current child's state, it is not uniform and we are done! else if (Result != i.IsChecked) { Uniform = false; break; } } return(!Uniform ? null : Result); }
void OnQueryOnExpandedChanged(CheckableSystemObject Item, bool Value) { foreach (var i in Item.Children) { i.QueryOnExpanded = Value; OnQueryOnExpandedChanged(i, Value); } }