Example #1
0
        /// <summary>
        /// 当项容被清空时,
        /// 解除事件处理程序。
        /// </summary>
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            CheckableListBoxItem ckItem = element as CheckableListBoxItem;

            ckItem.Checked   -= clbitem_Checked;
            ckItem.UnChecked -= clbitem_UnChecked;
            base.ClearContainerForItemOverride(element, item);
        }
Example #2
0
        void clbitem_UnChecked(object sender, RoutedEventArgs e)
        {
            CheckableListBoxItem citem = (CheckableListBoxItem)e.Source;
            object value = citem.Content;

            m_checkedItems.Remove(value);
            SetValue(CheckedItemsProperty, m_checkedItems);
        }
Example #3
0
        void clbitem_Checked(object sender, RoutedEventArgs e)
        {
            CheckableListBoxItem citem = (CheckableListBoxItem)(e.Source);
            object value = citem.Content;

            if (m_checkedItems.SingleOrDefault(o => object.ReferenceEquals(o, value)) == null)
            {
                m_checkedItems.Add(value);
                SetValue(CheckedItemsProperty, m_checkedItems);
            }
        }
Example #4
0
        private static void IsCheckedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CheckableListBoxItem lt = d as CheckableListBoxItem;

            if (lt != null)
            {
                if (e.NewValue != e.OldValue)
                {
                    bool b = (bool)e.NewValue;
                    if (b == true)
                    {
                        lt.RaiseCheckedEvent();
                    }
                    else
                    {
                        lt.RaiseUnCheckedEvent();
                    }
                }
            }
        }