static void UpdateOptionBinding(DependencyObject o)
        {
            ComboBox comboBox = o as ComboBox;
            CSharpFormattingOptionsContainer container = GetContainer(comboBox);
            FormattingOption option = GetFormattingOption(comboBox);

            if ((option != null) && (comboBox != null) && (container != null))
            {
                if (container != null)
                {
                    if (container.Parent != null)
                    {
                        // Add "default" entry in ComboBox
                        comboBox.Items.Add(new ComboBoxItem {
                            Content = (container.Parent ?? container).DefaultText,
                            Tag     = null
                        });
                        comboBox.SelectedIndex = 0;
                    }
                    else if (option.AlwaysAllowDefault)
                    {
                        // Also add "default" entry, but without changeable text by container
                        comboBox.Items.Add(new ComboBoxItem {
                            Content = "(default)",
                            Tag     = null
                        });
                        comboBox.SelectedIndex = 0;
                    }

                    Type optionType = container.GetOptionType(option.Option);
                    FillComboValues(comboBox, optionType);
                    UpdateComboBoxValue(container, option.Option, comboBox);

                    comboBox.SelectionChanged += ComboBox_SelectionChanged;
                    container.PropertyChanged += (sender, eventArgs) =>
                    {
                        if ((eventArgs.PropertyName == null) || (eventArgs.PropertyName == option.Option))
                        {
                            UpdateComboBoxValue(container, option.Option, comboBox);
                        }
                    };
                }
            }
        }
        static void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox != null)
            {
                FormattingOption option = GetFormattingOption(comboBox);
                CSharpFormattingOptionsContainer container = GetContainer(comboBox);
                if ((container != null) && (option != null))
                {
                    ComboBoxItem selectedItem = comboBox.SelectedItem as ComboBoxItem;
                    if (selectedItem != null)
                    {
                        // Set option to appropriate value
                        container.SetOption(option.Option, selectedItem.Tag);
                    }
                }
            }
        }
 public static void SetFormattingOption(Selector element, FormattingOption container)
 {
     element.SetValue(FormattingOptionProperty, container);
 }