Ejemplo n.º 1
0
        /// <summary>
        /// When Document Property Changed, the new Document needs to attached the event handlers of all comboboxes
        /// withing then new Document, and dettach handlers in old document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private static void DocumentPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RichTextBoxWithIntellisense textBox = sender as RichTextBoxWithIntellisense;

            if (textBox != null)
            {
                FlowDocument oldDocument = args.OldValue as FlowDocument;
                if (oldDocument != null)
                {
                    textBox.DettachEventHandlersFromAllComboBoxes(oldDocument);
                }
                FlowDocument newDocument = args.NewValue as FlowDocument;
                if (newDocument != null)
                {
                    textBox.AttachEventHandlersToAllComboBoxes(newDocument);
                }

                textBox.IsTextDirty = false;
            }
        }