示例#1
0
 private void ValidateParentChecked(InnerCheckItemCollection parent)
 {
     if (parent == null)
     {
         return;
     }
     parent.IsChecked = parent.AnyChildChecked();
     ValidateParentChecked(parent.Prarent);
 }
示例#2
0
        /*
         * 父元素回溯一步一步检测递归
         * 子元素集合迭代复制处理
         *
         */
        public override void CheckedChanged()
        {
            bool currentChecked = this.IsChecked;
            //迭代处理子元素
            List <InnerCheckItem> tempItems = new List <InnerCheckItem>();

            tempItems.AddRange(this.Items);
            for (int i = 0; i < tempItems.Count; i++)
            {
                InnerCheckItem tempItem = tempItems[i];
                tempItem.IsChecked = currentChecked;

                InnerCheckItemCollection tempCollection = tempItem as InnerCheckItemCollection;
                if (tempCollection != null)
                {
                    tempItems.AddRange(tempCollection.Items);
                }
            }

            base.CheckedChanged();
        }