private void ManageStylesButton_Click(object sender, RoutedEventArgs e)
 {
     var viewModel = new ManageNamingStylesDialogViewModel(_viewModel.NamingStyles, _viewModel.CodeStyleItems.ToList(), _notificationService);
     var dialog = new ManageNamingStylesInfoDialog(viewModel);
     if (dialog.ShowModal().Value == true)
     {
         _viewModel.UpdateStyleList(viewModel);
     }
 }
        internal void UpdateStyleList(ManageNamingStylesDialogViewModel viewModel)
        {
            var namingStyles = viewModel.Items
                               .Cast <NamingStyleViewModel>()
                               .Select(
                n =>
                new MutableNamingStyle(
                    new NamingStyle(
                        id: n.ID,
                        name: n.ItemName,
                        prefix: n.RequiredPrefix,
                        suffix: n.RequiredSuffix,
                        wordSeparator: n.WordSeparator,
                        capitalizationScheme: n.CapitalizationSchemes[
                            n.CapitalizationSchemeIndex
                        ].Capitalization
                        )
                    )
                );

            NamingStyles.Clear();
            foreach (var style in namingStyles)
            {
                NamingStyles.Add(style);
            }

            // The existing rules have had their Styles pulled out from underneath them, so
            // this goes through and resets them.

            foreach (var rule in CodeStyleItems)
            {
                var selectedStyle = rule.SelectedStyle;

                rule.NamingStyles.Clear();
                foreach (var style in namingStyles)
                {
                    rule.NamingStyles.Add(style);
                }

                // Set the SelectedStyle to null and then back to the actual selected
                // style to trigger the INotifyPropertyChanged event.

                rule.SelectedStyle = null;

                if (selectedStyle != null)
                {
                    rule.SelectedStyle = rule.NamingStyles.Single(n => n.ID == selectedStyle.ID);
                }
            }
        }