public virtual void OnToggleButtonIsCheckedChanged(object sender, RoutedEventArgs e)
        {
            ToggleButton button = e.OriginalSource as ToggleButton;

            if (button != null)
            {
                PropertyGridItem item = button.DataContext as PropertyGridItem;
                if (item != null && item.Property != null && item.Property.IsEnum && item.Property.IsFlagsEnum)
                {
                    if (button.IsChecked.HasValue)
                    {
                        ulong itemValue     = PropertyGridComboBoxExtension.EnumToUInt64(item.Property, item.Value);
                        ulong propertyValue = PropertyGridComboBoxExtension.EnumToUInt64(item.Property, item.Property.Value);
                        ulong newValue;
                        if (button.IsChecked.Value)
                        {
                            if (itemValue == 0)
                            {
                                newValue = 0;
                            }
                            else
                            {
                                newValue = propertyValue | itemValue;
                            }
                        }
                        else
                        {
                            newValue = propertyValue & ~itemValue;
                        }

                        object propValue = PropertyGridComboBoxExtension.EnumToObject(item.Property, newValue);
                        item.Property.Value = propValue;

                        ListBoxItem li = button.GetVisualSelfOrParent <ListBoxItem>();
                        if (li != null)
                        {
                            ItemsControl parent = ItemsControl.ItemsControlFromItemContainer(li);
                            if (parent != null)
                            {
                                if (button.IsChecked.Value && itemValue == 0)
                                {
                                    foreach (PropertyGridItem gridItem in parent.Items.OfType <PropertyGridItem>())
                                    {
                                        gridItem.IsChecked = PropertyGridComboBoxExtension.EnumToUInt64(item.Property, gridItem.Value) == 0;
                                    }
                                }
                                else
                                {
                                    foreach (PropertyGridItem gridItem in parent.Items.OfType <PropertyGridItem>())
                                    {
                                        ulong gridItemValue = PropertyGridComboBoxExtension.EnumToUInt64(item.Property, gridItem.Value);
                                        if (gridItemValue == 0)
                                        {
                                            gridItem.IsChecked = newValue == 0;
                                            continue;
                                        }

                                        gridItem.IsChecked = (newValue & gridItemValue) == gridItemValue;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }